Return to Snippet

Revision: 2988
at May 21, 2007 20:17 by IanLewis


Initial Code
//recursively creates a folder.
function mk_dir($path, $rights = 0777) {//{{{
  //$folder_path = array(strstr($path, '.') ? dirname($path) : $path);
  if (!@is_dir($path)) {
    $folder_path = array($path);
  } else {
    return;
  }
  
  while(!@is_dir(dirname(end($folder_path)))
         && dirname(end($folder_path)) != '/'
         && dirname(end($folder_path)) != '.'
         && dirname(end($folder_path)) != '')
  {
    array_push($folder_path, dirname(end($folder_path)));
  }

  while($parent_folder_path = array_pop($folder_path)) {
    if(!@mkdir($parent_folder_path, $rights)) {
      user_error("Can't create folder \"$parent_folder_path\".\n");
    }
  }
}//}}}

Initial URL


Initial Description
Recursively creates a directory.

Initial Title
Make directory recursively

Initial Tags
directory

Initial Language
PHP