Changeset View
Changeset View
Standalone View
Standalone View
src/filesystem/Filesystem.php
| Show First 20 Lines • Show All 604 Lines • ▼ Show 20 Lines | public static function getMimeType( | ||||
| } | } | ||||
| return $mime_type; | return $mime_type; | ||||
| } | } | ||||
| /* -( Directories )-------------------------------------------------------- */ | /* -( Directories )-------------------------------------------------------- */ | ||||
| /** | |||||
| * Build a path from the pieces provided using the system's directory | |||||
| * separator. | |||||
| * | |||||
| * @param ...string The list of directory paths to be joined | |||||
| * @return string The built, full directory path. | |||||
| */ | |||||
| public static function buildPath() { | |||||
| return implode(DIRECTORY_SEPARATOR, func_get_args()); | |||||
| } | |||||
| /** | /** | ||||
| * Create a directory in a manner similar to mkdir(), but throw detailed | * Create a directory in a manner similar to mkdir(), but throw detailed | ||||
| * exceptions on failure. | * exceptions on failure. | ||||
| * | * | ||||
| * @param string Path to directory. The parent directory must exist and | * @param string Path to directory. The parent directory must exist and | ||||
| * be writable. | * be writable. | ||||
| * @param int Permission umask. Note that umask is in octal, so you | * @param int Permission umask. Note that umask is in octal, so you | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | /* -( Directories )-------------------------------------------------------- */ | ||||
| * (defaulting to "/"). Iterating over them walks from the path to the root. | * (defaulting to "/"). Iterating over them walks from the path to the root. | ||||
| * | * | ||||
| * @param string Path, absolute or relative to PWD. | * @param string Path, absolute or relative to PWD. | ||||
| * @param string The root directory. | * @param string The root directory. | ||||
| * @return list<string> List of parent paths, including the provided path. | * @return list<string> List of parent paths, including the provided path. | ||||
| * @task directory | * @task directory | ||||
| */ | */ | ||||
| public static function walkToRoot($path, $root = '/') { | public static function walkToRoot($path, $root = '/') { | ||||
| if (phutil_is_windows()) { | |||||
| $win_root = getenv('HOMEDRIVE'); | |||||
eadler: won't this fail if `arc` is run on a project checked out to a drive other than `%HOMEDRIVE%`? | |||||
Not Done Inline ActionsPossibly. That said there's not reliable equivalent of / on Windows AFAIK. If you think getting the install drive for arc is a better option, I can update accordingly. Btw. this section is gonna change substantially since there are some other issues I realized when fixing tests. Updating coming soon. BYK: Possibly. That said there's not reliable equivalent of `/` on Windows AFAIK. If you think… | |||||
| $root = explode('/', $root); | |||||
| $path = explode('/', $path); | |||||
| if (!$root[0]) { | |||||
| $root[0] = $win_root; | |||||
| } | |||||
| if (!$path[0]) { | |||||
| $path[0] = $win_root; | |||||
| } | |||||
| $root = implode(DIRECTORY_SEPARATOR, $root); | |||||
| $path = implode(DIRECTORY_SEPARATOR, $path); | |||||
| } | |||||
| $path = self::resolvePath($path); | $path = self::resolvePath($path); | ||||
| $root = self::resolvePath($root); | $root = self::resolvePath($root); | ||||
| if (is_link($path)) { | if (is_link($path)) { | ||||
| $path = realpath($path); | $path = realpath($path); | ||||
| } | } | ||||
| if (is_link($root)) { | if (is_link($root)) { | ||||
| $root = realpath($root); | $root = realpath($root); | ||||
| Show All 16 Lines | public static function walkToRoot($path, $root = '/') { | ||||
| while (true) { | while (true) { | ||||
| if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
| $next = implode(DIRECTORY_SEPARATOR, $parts); | $next = implode(DIRECTORY_SEPARATOR, $parts); | ||||
| } else { | } else { | ||||
| $next = DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts); | $next = DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts); | ||||
| } | } | ||||
| if ($next) { | |||||
| $walk[] = $next; | $walk[] = $next; | ||||
| } | |||||
| if ($next == $root) { | if ($next == $root) { | ||||
| break; | break; | ||||
| } | } | ||||
| if (!$parts) { | if (!$parts) { | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines | |||||
won't this fail if arc is run on a project checked out to a drive other than %HOMEDRIVE%?