mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +00:00
ls: Fix issue with Windows and dangling symbolic links
- Windows hidden file attribute determination would assume symbolic link to be valid and would panic - Check symbolic link's attributes if the link points to non-existing file
This commit is contained in:
parent
d0039df8c3
commit
3b641afadc
1 changed files with 2 additions and 1 deletions
|
@ -1270,7 +1270,8 @@ fn sort_entries(entries: &mut Vec<PathData>, config: &Config) {
|
|||
|
||||
#[cfg(windows)]
|
||||
fn is_hidden(file_path: &DirEntry) -> bool {
|
||||
let metadata = fs::metadata(file_path.path()).unwrap();
|
||||
let path = file_path.path();
|
||||
let metadata = fs::metadata(&path).unwrap_or_else(|_| fs::symlink_metadata(&path).unwrap());
|
||||
let attr = metadata.file_attributes();
|
||||
(attr & 0x2) > 0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue