about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorPeter Atashian <retep998@gmail.com>2018-02-03 01:45:58 -0500
committerPeter Atashian <retep998@gmail.com>2018-02-03 01:45:58 -0500
commitf4c83693f9e2445b441dfcf43838697d25d1a11f (patch)
tree847cb7696a10863253a5a1df27892c7861457443 /src/libstd
parent259b0329d42ea9ce971c0c8c9ff72f8496a73b9e (diff)
downloadrust-f4c83693f9e2445b441dfcf43838697d25d1a11f.tar.gz
rust-f4c83693f9e2445b441dfcf43838697d25d1a11f.zip
Go back to files directories and symlinks being mutually exclusive
Be smarter about what a symlink is however
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/windows/fs.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs
index a49c3569b02..512c9cb838c 100644
--- a/src/libstd/sys/windows/fs.rs
+++ b/src/libstd/sys/windows/fs.rs
@@ -522,21 +522,27 @@ impl FileType {
             reparse_tag: reparse_tag,
         }
     }
-
     pub fn is_dir(&self) -> bool {
-        self.attributes & c::FILE_ATTRIBUTE_DIRECTORY != 0
+        !self.is_symlink() && self.is_directory()
     }
     pub fn is_file(&self) -> bool {
-        self.attributes & c::FILE_ATTRIBUTE_DIRECTORY == 0
+        !self.is_symlink() && !self.is_directory()
     }
     pub fn is_symlink(&self) -> bool {
-        self.is_reparse_point() && (
-            self.reparse_tag == c::IO_REPARSE_TAG_SYMLINK ||
-            self.reparse_tag == c::IO_REPARSE_TAG_MOUNT_POINT)
+        self.is_reparse_point() && self.is_reparse_tag_name_surrogate()
+    }
+    pub fn is_symlink_dir(&self) -> bool {
+        self.is_symlink() && self.is_directory()
+    }
+    fn is_directory(&self) -> bool {
+        self.attributes & c::FILE_ATTRIBUTE_DIRECTORY != 0
     }
-    pub fn is_reparse_point(&self) -> bool {
+    fn is_reparse_point(&self) -> bool {
         self.attributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0
     }
+    fn is_reparse_tag_name_surrogate(&self) -> bool {
+        self.reparse_tag & 0x20000000 != 0
+    }
 }
 
 impl DirBuilder {
@@ -607,12 +613,10 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
     for child in readdir(path)? {
         let child = child?;
         let child_type = child.file_type()?;
-        if child_type.is_dir() {
-            if child_type.is_reparse_point() {
-                rmdir(&child.path())?;
-            } else {
-                remove_dir_all_recursive(&child.path())?;
-            }
+        if child_type.is_symlink_dir() {
+            rmdir(&child.path())?;
+        } else if child_type.is_dir() {
+            remove_dir_all_recursive(&child.path())?;
         } else {
             unlink(&child.path())?;
         }