1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

ls: On Windows don't display files hidden by NTFS (#1662)

This little check, allows us to hide the files that
shouldn't be shown on the listing on Windows operating
systems.

Just like the "dot" in UNIX based operating systems
Windows uses its own file attributes to determine if a file
is hidden or not.

The lack of support for this option is normally an annoyance
for many users, this commit adds full support for this feature
This commit is contained in:
Diego Magdaleno 2020-12-19 10:54:28 -06:00 committed by GitHub
parent 469abf2427
commit 8b12686888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View file

@ -310,3 +310,29 @@ fn test_ls_human() {
assert!(result.success);
assert!(result.stdout.contains("1.02M"));
}
#[cfg(windows)]
#[test]
fn test_ls_hidden_windows() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let file = "hiddenWindowsFileNoDot";
at.touch(file);
// hide the file
scene
.cmd("attrib")
.arg("+h")
.arg("+S")
.arg("+r")
.arg(file)
.run();
let result = scene.ucmd().run();
println!("stderr = {:?}", result.stderr);
println!("stdout = {:?}", result.stdout);
assert!(result.success);
let result = scene.ucmd().arg("-a").run();
println!("stderr = {:?}", result.stderr);
println!("stdout = {:?}", result.stdout);
assert!(result.success);
assert!(result.stdout.contains(file));
}