Page MenuHomePhabricator

D19591.diff
No OneTemporary

D19591.diff

diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php
--- a/src/filesystem/Filesystem.php
+++ b/src/filesystem/Filesystem.php
@@ -777,22 +777,36 @@
* @return list<string> List of parent paths, including the provided path.
* @task directory
*/
- public static function walkToRoot($path, $root = '/') {
+ public static function walkToRoot($path, $root = null) {
$path = self::resolvePath($path);
- $root = self::resolvePath($root);
if (is_link($path)) {
$path = realpath($path);
}
- if (is_link($root)) {
- $root = realpath($root);
- }
- // NOTE: We don't use `isDescendant()` here because we don't want to reject
- // paths which don't exist on disk.
- $root_list = new FileList(array($root));
- if (!$root_list->contains($path)) {
- return array();
+ // NOTE: On Windows, paths start like "C:\", so "/" does not contain
+ // every other path. We could possibly special case "/" to have the same
+ // meaning on Windows that it does on Linux, but just special case the
+ // common case for now. See PHI817.
+ if ($root !== null) {
+ $root = self::resolvePath($root);
+
+ if (is_link($root)) {
+ $root = realpath($root);
+ }
+
+ // NOTE: We don't use `isDescendant()` here because we don't want to
+ // reject paths which don't exist on disk.
+ $root_list = new FileList(array($root));
+ if (!$root_list->contains($path)) {
+ return array();
+ }
+ } else {
+ if (phutil_is_windows()) {
+ $root = null;
+ } else {
+ $root = '/';
+ }
}
$walk = array();

File Metadata

Mime Type
text/plain
Expires
Sun, May 12, 5:42 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6290136
Default Alt Text
D19591.diff (1 KB)

Event Timeline