From b4d446284049a5f6fd6f5717196f92663cdf6f2a Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Fri, 16 Feb 2024 11:36:54 +0800 Subject: [PATCH] :art: :hammer: simplify the windows cfg Signed-off-by: Wei Zhang --- src/meta/mod.rs | 3 ++- src/meta/name.rs | 4 +--- src/meta/windows_attributes.rs | 7 +------ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/meta/mod.rs b/src/meta/mod.rs index 1b0e4ebf6..6c65147f1 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -12,8 +12,9 @@ mod permissions; mod permissions_or_attributes; mod size; mod symlink; -mod windows_attributes; +#[cfg(windows)] +mod windows_attributes; #[cfg(windows)] mod windows_utils; diff --git a/src/meta/name.rs b/src/meta/name.rs index 4d6ea6cb5..81f28b03c 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -205,9 +205,7 @@ impl Ord for Name { impl PartialOrd for Name { fn partial_cmp(&self, other: &Self) -> Option { - self.name - .to_lowercase() - .partial_cmp(&other.name.to_lowercase()) + Some(self.cmp(other)) } } diff --git a/src/meta/windows_attributes.rs b/src/meta/windows_attributes.rs index fa4a0319f..6fb8a23b7 100644 --- a/src/meta/windows_attributes.rs +++ b/src/meta/windows_attributes.rs @@ -1,12 +1,10 @@ -#[cfg(windows)] use crate::{ color::{ColoredString, Colors, Elem}, flags::Flags, }; -#[cfg(windows)] + use std::os::windows::fs::MetadataExt; -#[cfg(windows)] #[derive(Debug, Clone)] pub struct WindowsAttributes { pub archive: bool, @@ -15,7 +13,6 @@ pub struct WindowsAttributes { pub system: bool, } -#[cfg(windows)] pub fn get_attributes(metadata: &std::fs::Metadata) -> WindowsAttributes { use windows::Win32::Storage::FileSystem::{ FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_READONLY, @@ -34,7 +31,6 @@ pub fn get_attributes(metadata: &std::fs::Metadata) -> WindowsAttributes { } } -#[cfg(windows)] impl WindowsAttributes { pub fn render(&self, colors: &Colors, _flags: &Flags) -> ColoredString { let res = [ @@ -64,7 +60,6 @@ impl WindowsAttributes { } } -#[cfg(windows)] #[cfg(test)] mod test { use std::fs;