mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #4014 from tertsdiepraam/ls-windows-permissions
`ls`, `stat`: Show more info in long format on Windows
This commit is contained in:
commit
e4fe2b10fa
2 changed files with 18 additions and 4 deletions
|
@ -402,12 +402,26 @@ pub fn canonicalize<P: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
#[allow(unused_variables)]
|
|
||||||
pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> String {
|
pub fn display_permissions(metadata: &fs::Metadata, display_file_type: bool) -> String {
|
||||||
|
let write = if metadata.permissions().readonly() {
|
||||||
|
'-'
|
||||||
|
} else {
|
||||||
|
'w'
|
||||||
|
};
|
||||||
|
|
||||||
if display_file_type {
|
if display_file_type {
|
||||||
return String::from("----------");
|
let file_type = if metadata.is_symlink() {
|
||||||
|
'l'
|
||||||
|
} else if metadata.is_dir() {
|
||||||
|
'd'
|
||||||
|
} else {
|
||||||
|
'-'
|
||||||
|
};
|
||||||
|
|
||||||
|
format!("{0}r{1}xr{1}xr{1}x", file_type, write)
|
||||||
|
} else {
|
||||||
|
format!("r{0}xr{0}xr{0}x", write)
|
||||||
}
|
}
|
||||||
String::from("---------")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
|
@ -966,7 +966,7 @@ fn test_ls_long() {
|
||||||
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
|
result.stdout_matches(&Regex::new(r"[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}.*").unwrap());
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
result.stdout_contains("---------- 1 somebody somegroup");
|
result.stdout_matches(&Regex::new(r"[-dl](r[w-]x){3}.*").unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue