Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15506520
D19591.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D19591.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 16, 11:57 AM (1 w, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7724664
Default Alt Text
D19591.diff (1 KB)
Attached To
Mode
D19591: Fix Filesytem::walkToRoot() on Windows with default ("/") root
Attached
Detach File
Event Timeline
Log In to Comment