This commit is contained in:
Lynne Megido 2021-02-06 21:53:44 +10:00
parent e3466a8912
commit 9be33cd90f
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -61,11 +61,10 @@ impl Display for ScanError {
#[cfg(windows)] #[cfg(windows)]
fn is_hidden(entry: &DirEntry) -> bool { fn is_hidden(entry: &DirEntry) -> bool {
use std::os::windows::prelude::*; use std::os::windows::prelude::*;
use std::fs; std::fs::metadata(entry) // try to get metadata for file
fs::metadata(entry) // try to get metadata for file
.map_or( .map_or(
false, // if getting metadata/attributes fails, assume it's not hidden false, // if getting metadata/attributes fails, assume it's not hidden
|f| f.file_attributes() & 0x2 // flag for hidden - https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants |f| f.file_attributes() & 0x2 > 0 // flag for hidden - https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
) )
} }