function normalizePath($path, $to_type = FS_SEPARATOR_LOCAL) { $path = Fs :: convertSeparators($path, $to_type); $separator = Fs :: separator($to_type); $path = Fs :: _normalizeSeparators($path, $separator); $path_elements= explode($separator, $path); $newpath_elements= array(); foreach ($path_elements as $path_element) { if ($path_element == '.') continue; if ($path_element == '..' && count($newpath_elements) > 0) array_pop($newpath_elements); else $newpath_elements[] = $path_element; } if ( count( $newpath_elements) == 0 ) $newpath_elements[] = '.'; $path = implode($separator, $newpath_elements); return $path; }