Source for file mkdirr.function.php

Documentation is available at mkdirr.function.php

  1. <?php
  2. /**
  3. * @package harmoni.utilities
  4. */
  5.  
  6. /**
  7. * Create a directory structure recursively
  8. *
  9. * @author Aidan Lister <aidan@php.net>
  10. * @version 1.0.0
  11. * @param string $pathname The directory structure to create
  12. * @return bool Returns TRUE on success, FALSE on failure
  13. */
  14. function mkdirr($pathname, $mode = null)
  15. {
  16. // Check if directory already exists
  17. if (is_dir($pathname) || empty($pathname)) {
  18. return true;
  19. }
  20.  
  21. // Ensure a file does not already exist with the same name
  22. if (is_file($pathname)) {
  23. trigger_error('mkdirr() File exists', E_USER_WARNING);
  24. return false;
  25. }
  26.  
  27. // Crawl up the directory tree
  28. $next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
  29. if (mkdirr($next_pathname, $mode)) {
  30. if (!file_exists($pathname)) {
  31. //changed the following 4 lines to allow custom permissions
  32. $old = umask(0);
  33. $returnValue = mkdir($pathname, $mode);
  34. umask($old);
  35. return $returnValue;
  36.  
  37. }
  38. }
  39.  
  40. return false;
  41. }
  42.  
  43. ?>

Documentation generated on Wed, 19 Sep 2007 10:25:06 -0400 by phpDocumentor 1.3.0RC3