🎨 🔨 simplify the windows cfg

Signed-off-by: Wei Zhang <kweizh@gmail.com>
This commit is contained in:
Wei Zhang 2024-02-16 11:36:54 +08:00
parent bc6c930831
commit b4d4462840
3 changed files with 4 additions and 10 deletions

View file

@ -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;

View file

@ -205,9 +205,7 @@ impl Ord for Name {
impl PartialOrd for Name {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.name
.to_lowercase()
.partial_cmp(&other.name.to_lowercase())
Some(self.cmp(other))
}
}

View file

@ -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;