Просмотр исходного кода

feat: Adds filtering on Windows hidden files

Adds an extra check on attributes().hidden on Windows
This hides Windows hidden files whenever dot files are also filtered out

Resolves #212
Aaron Lamb 2 лет назад
Родитель
Сommit
8e93cf1bd5
1 измененных файлов с 16 добавлено и 3 удалено
  1. 16 3
      src/fs/dir.rs

+ 16 - 3
src/fs/dir.rs

@@ -129,11 +129,24 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
                     }
                 }
 
-                return Some(File::from_args(path.clone(), self.dir, filename, self.deref_links)
-                                 .map_err(|e| (path.clone(), e)))
+                let file = File::from_args(
+                    path.clone(),
+                    self.dir,
+                    filename,
+                    self.deref_links
+                ).map_err(|e| (path.clone(), e));
+
+                // Windows has its own concept of hidden files, with a flag
+                // stored in the file's attributes
+                #[cfg(windows)]
+                if !self.dotfiles && file.as_ref().is_ok_and(|f| f.attributes().hidden) {
+                    continue;
+                }
+
+                return Some(file);
             }
 
-            return None
+            return None;
         }
     }
 }