Chester Liu 4 лет назад
Родитель
Сommit
e874584a55
3 измененных файлов с 38 добавлено и 32 удалено
  1. 24 20
      src/fs/file.rs
  2. 1 0
      src/options/filter.rs
  3. 13 12
      src/output/file_name.rs

+ 24 - 20
src/fs/file.rs

@@ -325,15 +325,8 @@ impl<'dir> File<'dir> {
     ///
     /// Block and character devices return their device IDs, because they
     /// usually just have a file size of zero.
+    #[cfg(unix)]
     pub fn size(&self) -> f::Size {
-        #[cfg(windows)]
-        if self.is_directory() {
-            f::Size::None
-        }
-        else {
-            f::Size::Some(self.metadata.len())
-        }
-        #[cfg(unix)]
         if self.is_directory() {
             f::Size::None
         }
@@ -349,6 +342,16 @@ impl<'dir> File<'dir> {
         }
     }
 
+    #[cfg(windows)]
+    pub fn size(&self) -> f::Size {
+        if self.is_directory() {
+            f::Size::None
+        }
+        else {
+            f::Size::Some(self.metadata.len())
+        }
+    }
+
     /// This file’s last modified timestamp, if available on this platform.
     pub fn modified_time(&self) -> Option<SystemTime> {
         self.metadata.modified().ok()
@@ -394,18 +397,6 @@ impl<'dir> File<'dir> {
     /// This is used a the leftmost character of the permissions column.
     /// The file type can usually be guessed from the colour of the file, but
     /// ls puts this character there.
-    #[cfg(windows)]
-    pub fn type_char(&self) -> f::Type {
-        if self.is_file() {
-            f::Type::File
-        }
-        else if self.is_directory() {
-            f::Type::Directory
-        }
-        else {
-            f::Type::Special
-        }
-    }
     #[cfg(unix)]
     pub fn type_char(&self) -> f::Type {
         if self.is_file() {
@@ -434,6 +425,19 @@ impl<'dir> File<'dir> {
         }
     }
 
+    #[cfg(windows)]
+    pub fn type_char(&self) -> f::Type {
+        if self.is_file() {
+            f::Type::File
+        }
+        else if self.is_directory() {
+            f::Type::Directory
+        }
+        else {
+            f::Type::Special
+        }
+    }
+
     /// This file’s permissions, with flags for each bit.
     #[cfg(unix)]
     pub fn permissions(&self) -> f::Permissions {

+ 1 - 0
src/options/filter.rs

@@ -78,6 +78,7 @@ impl SortField {
             "age" | "old" | "oldest" => {
                 Self::ModifiedAge
             }
+
             "ch" | "changed" => {
                 Self::ChangedDate
             }

+ 13 - 12
src/output/file_name.rs

@@ -235,18 +235,6 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
 
     /// The character to be displayed after a file when classifying is on, if
     /// the file’s type has one associated with it.
-    #[cfg(windows)]
-    fn classify_char(&self) -> Option<&'static str> {
-        if self.file.is_directory() {
-            Some("/")
-        }
-        else if self.file.is_link() {
-            Some("@")
-        }
-        else {
-            None
-        }
-    }
     #[cfg(unix)]
     fn classify_char(&self) -> Option<&'static str> {
         if self.file.is_executable_file() {
@@ -269,6 +257,19 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
         }
     }
 
+    #[cfg(windows)]
+    fn classify_char(&self) -> Option<&'static str> {
+        if self.file.is_directory() {
+            Some("/")
+        }
+        else if self.file.is_link() {
+            Some("@")
+        }
+        else {
+            None
+        }
+    }
+
     /// Returns at least one ANSI-highlighted string representing this file’s
     /// name using the given set of colours.
     ///