File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -910,9 +910,7 @@ impl Stater {
910910 // raw mode in hex
911911 'f' => OutputType :: UnsignedHex ( meta. mode ( ) as u64 ) ,
912912 // file type
913- 'F' => OutputType :: Str (
914- pretty_filetype ( meta. mode ( ) as mode_t , meta. len ( ) ) . to_owned ( ) ,
915- ) ,
913+ 'F' => OutputType :: Str ( pretty_filetype ( meta. mode ( ) as mode_t , meta. len ( ) ) ) ,
916914 // group ID of owner
917915 'g' => OutputType :: Unsigned ( meta. gid ( ) as u64 ) ,
918916 // group name of owner
Original file line number Diff line number Diff line change @@ -880,7 +880,7 @@ where
880880}
881881
882882#[ cfg( unix) ]
883- pub fn pretty_filetype < ' a > ( mode : mode_t , size : u64 ) -> & ' a str {
883+ pub fn pretty_filetype ( mode : mode_t , size : u64 ) -> String {
884884 match mode & S_IFMT {
885885 S_IFREG => {
886886 if size == 0 {
@@ -896,9 +896,9 @@ pub fn pretty_filetype<'a>(mode: mode_t, size: u64) -> &'a str {
896896 S_IFIFO => "fifo" ,
897897 S_IFSOCK => "socket" ,
898898 // TODO: Other file types
899- // See coreutils/gnulib/lib/file-type.c // spell-checker:disable-line
900- _ => "weird file" ,
899+ _ => return format ! ( "weird file ({:07o})" , mode & S_IFMT ) ,
901900 }
901+ . to_owned ( )
902902}
903903
904904pub fn pretty_fstype < ' a > ( fstype : i64 ) -> Cow < ' a , str > {
@@ -1036,7 +1036,7 @@ mod tests {
10361036 assert_eq ! ( "character special file" , pretty_filetype( S_IFCHR , 0 ) ) ;
10371037 assert_eq ! ( "regular file" , pretty_filetype( S_IFREG , 1 ) ) ;
10381038 assert_eq ! ( "regular empty file" , pretty_filetype( S_IFREG , 0 ) ) ;
1039- assert_eq ! ( "weird file" , pretty_filetype( 0 , 0 ) ) ;
1039+ assert_eq ! ( "weird file (0000000) " , pretty_filetype( 0 , 0 ) ) ;
10401040 }
10411041
10421042 #[ test]
You can’t perform that action at this time.
0 commit comments