From e874584a554576cdd7681365e1f80d3ba0983d1d Mon Sep 17 00:00:00 2001 From: Chester Liu Date: Sun, 28 Mar 2021 09:31:03 +0800 Subject: [PATCH] Try to fix CI --- src/fs/file.rs | 44 ++++++++++++++++++++++------------------- src/options/filter.rs | 1 + src/output/file_name.rs | 25 ++++++++++++----------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/fs/file.rs b/src/fs/file.rs index f4cf927..94c708a 100644 --- a/src/fs/file.rs +++ b/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 { 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 { diff --git a/src/options/filter.rs b/src/options/filter.rs index a87cee3..ad88ff7 100644 --- a/src/options/filter.rs +++ b/src/options/filter.rs @@ -78,6 +78,7 @@ impl SortField { "age" | "old" | "oldest" => { Self::ModifiedAge } + "ch" | "changed" => { Self::ChangedDate } diff --git a/src/output/file_name.rs b/src/output/file_name.rs index 46842df..31bde71 100644 --- a/src/output/file_name.rs +++ b/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. ///