mut me is a must!

This commit is contained in:
Ahmed Hassan 2025-07-29 22:42:08 +04:00
parent e774044cad
commit 1c187eb0a5

View file

@ -1,4 +1,7 @@
use std::{fs::{FileType, Metadata}, time::SystemTime};
use std::{
fs::{FileType, Metadata},
time::SystemTime,
};
use yazi_macro::{unix_either, win_either};
use yazi_shared::url::Url;
@ -77,7 +80,7 @@ impl Cha {
#[inline]
pub fn from_dummy(_url: &Url, ft: Option<FileType>) -> Self {
let me = ft.map(Self::from_half_ft).unwrap_or_default();
let mut me = ft.map(Self::from_half_ft).unwrap_or_default();
#[cfg(unix)]
if _url.urn().is_hidden() {
me.kind |= ChaKind::HIDDEN;
@ -129,7 +132,10 @@ impl Cha {
fn from_just_meta(m: &Metadata) -> Self {
#[cfg(unix)]
use std::{os::unix::{fs::MetadataExt, prelude::PermissionsExt}, time::{Duration, UNIX_EPOCH}};
use std::{
os::unix::{fs::MetadataExt, prelude::PermissionsExt},
time::{Duration, UNIX_EPOCH},
};
let mut kind = ChaKind::empty();
if m.is_dir() {
@ -178,7 +184,9 @@ impl Cha {
impl Cha {
#[inline]
pub const fn is_dir(&self) -> bool { self.kind.contains(ChaKind::DIR) }
pub const fn is_dir(&self) -> bool {
self.kind.contains(ChaKind::DIR)
}
#[inline]
pub const fn is_hidden(&self) -> bool {
@ -189,13 +197,19 @@ impl Cha {
}
#[inline]
pub const fn is_link(&self) -> bool { self.kind.contains(ChaKind::LINK) }
pub const fn is_link(&self) -> bool {
self.kind.contains(ChaKind::LINK)
}
#[inline]
pub const fn is_orphan(&self) -> bool { self.kind.contains(ChaKind::ORPHAN) }
pub const fn is_orphan(&self) -> bool {
self.kind.contains(ChaKind::ORPHAN)
}
#[inline]
pub const fn is_dummy(&self) -> bool { self.kind.contains(ChaKind::DUMMY) }
pub const fn is_dummy(&self) -> bool {
self.kind.contains(ChaKind::DUMMY)
}
#[inline]
pub const fn is_block(&self) -> bool {
@ -218,8 +232,12 @@ impl Cha {
}
#[inline]
pub const fn is_exec(&self) -> bool { unix_either!(self.mode & libc::S_IXUSR != 0, false) }
pub const fn is_exec(&self) -> bool {
unix_either!(self.mode & libc::S_IXUSR != 0, false)
}
#[inline]
pub const fn is_sticky(&self) -> bool { unix_either!(self.mode & libc::S_ISVTX != 0, false) }
pub const fn is_sticky(&self) -> bool {
unix_either!(self.mode & libc::S_ISVTX != 0, false)
}
}