function mkdir($dir, $perm=0777, $parents=true) { $dir = fs :: clean_path($dir); if(is_dir($dir)) return true; if(!$parents) return fs :: _do_mkdir($dir, $perm); $separator = fs :: separator(); $path_elements = fs :: explode_path($dir); if (count($path_elements) == 0) return true; $index = fs :: _get_first_existent_path_index($path_elements, $separator); if($index === false) { debug :: write_error('failed to find first existent path', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); return false; } $offset_path = ''; for ($i=0; $i < $index; $i++) { $offset_path .= $path_elements[$i] . $separator; } for ($i=$index; $i < count($path_elements); $i++) { $offset_path .= $path_elements[$i] . $separator; if (!fs :: _do_mkdir($offset_path, $perm)) return false; } return true; }