mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #2858 from moko256/moko256_ls_metadata_in_is_hidden
ls: On Windows use metadata owned by DirEntry instead of retrieved one additionaly
This commit is contained in:
commit
c69380a193
2 changed files with 36 additions and 2 deletions
|
@ -1412,8 +1412,7 @@ fn sort_entries(entries: &mut Vec<PathData>, config: &Config) {
|
|||
fn is_hidden(file_path: &DirEntry) -> bool {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let path = file_path.path();
|
||||
let metadata = fs::metadata(&path).unwrap_or_else(|_| fs::symlink_metadata(&path).unwrap());
|
||||
let metadata = file_path.metadata().unwrap();
|
||||
let attr = metadata.file_attributes();
|
||||
(attr & 0x2) > 0
|
||||
}
|
||||
|
|
|
@ -1642,6 +1642,41 @@ fn test_ls_hidden_windows() {
|
|||
scene.ucmd().arg("-a").succeeds().stdout_contains(file);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn test_ls_hidden_link_windows() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let file = "visibleWindowsFileNoDot";
|
||||
at.touch(file);
|
||||
|
||||
let link = "hiddenWindowsLinkNoDot";
|
||||
at.symlink_dir(file, link);
|
||||
// hide the link
|
||||
scene.cmd("attrib").arg("/l").arg("+h").arg(link).succeeds();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.succeeds()
|
||||
.stdout_contains(file)
|
||||
.stdout_does_not_contain(link);
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-a")
|
||||
.succeeds()
|
||||
.stdout_contains(file)
|
||||
.stdout_contains(link);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn test_ls_success_on_c_drv_root_windows() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
scene.ucmd().arg("C:\\").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ls_version_sort() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue