Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/uu/stat/src/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,9 +910,7 @@ impl Stater {
// raw mode in hex
'f' => OutputType::UnsignedHex(meta.mode() as u64),
// file type
'F' => OutputType::Str(
pretty_filetype(meta.mode() as mode_t, meta.len()).to_owned(),
),
'F' => OutputType::Str(pretty_filetype(meta.mode() as mode_t, meta.len())),
// group ID of owner
'g' => OutputType::Unsigned(meta.gid() as u64),
// group name of owner
Expand Down
8 changes: 4 additions & 4 deletions src/uucore/src/lib/features/fsext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ where
}

#[cfg(unix)]
pub fn pretty_filetype<'a>(mode: mode_t, size: u64) -> &'a str {
pub fn pretty_filetype(mode: mode_t, size: u64) -> String {
match mode & S_IFMT {
S_IFREG => {
if size == 0 {
Expand All @@ -896,9 +896,9 @@ pub fn pretty_filetype<'a>(mode: mode_t, size: u64) -> &'a str {
S_IFIFO => "fifo",
S_IFSOCK => "socket",
// TODO: Other file types
// See coreutils/gnulib/lib/file-type.c // spell-checker:disable-line
_ => "weird file",
_ => return format!("weird file ({:07o})", mode & S_IFMT),
}
.to_owned()
}

pub fn pretty_fstype<'a>(fstype: i64) -> Cow<'a, str> {
Expand Down Expand Up @@ -1036,7 +1036,7 @@ mod tests {
assert_eq!("character special file", pretty_filetype(S_IFCHR, 0));
assert_eq!("regular file", pretty_filetype(S_IFREG, 1));
assert_eq!("regular empty file", pretty_filetype(S_IFREG, 0));
assert_eq!("weird file", pretty_filetype(0, 0));
assert_eq!("weird file (0000000)", pretty_filetype(0, 0));
}

#[test]
Expand Down
Loading