Num links added to ls -l output (#2496)

This commit is contained in:
Chris Gillespie 2020-09-06 09:36:50 -07:00 committed by GitHub
parent 79cc725aff
commit 5a725f9651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View File

@ -874,8 +874,18 @@ pub(crate) fn dir_entry_dict(
#[cfg(unix)] #[cfg(unix)]
{ {
for column in [ for column in [
"name", "type", "target", "readonly", "mode", "uid", "group", "size", "created", "name",
"accessed", "modified", "type",
"target",
"num_links",
"readonly",
"mode",
"uid",
"group",
"size",
"created",
"accessed",
"modified",
] ]
.iter() .iter()
{ {
@ -942,6 +952,9 @@ pub(crate) fn dir_entry_dict(
UntaggedValue::string(umask::Mode::from(mode).to_string()), UntaggedValue::string(umask::Mode::from(mode).to_string()),
); );
let nlinks = md.nlink();
dict.insert_untagged("num_links", UntaggedValue::string(nlinks.to_string()));
if let Some(user) = users::get_user_by_uid(md.uid()) { if let Some(user) = users::get_user_by_uid(md.uid()) {
dict.insert_untagged( dict.insert_untagged(
"uid", "uid",

View File

@ -279,8 +279,18 @@ fn list_all_columns() {
#[cfg(unix)] #[cfg(unix)]
{ {
[ [
"name", "type", "target", "readonly", "mode", "uid", "group", "size", "name",
"created", "accessed", "modified", "type",
"target",
"num_links",
"readonly",
"mode",
"uid",
"group",
"size",
"created",
"accessed",
"modified",
] ]
.join("") .join("")
} }