mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
c6b39e2e9f
commit
12bd678539
2 changed files with 10 additions and 8 deletions
|
|
@ -73,7 +73,14 @@ impl Files {
|
||||||
reg.add_field_method_get("accessed", |_, me| {
|
reg.add_field_method_get("accessed", |_, me| {
|
||||||
Ok(me.accessed.and_then(|t| t.duration_since(UNIX_EPOCH).map(|d| d.as_secs_f64()).ok()))
|
Ok(me.accessed.and_then(|t| t.duration_since(UNIX_EPOCH).map(|d| d.as_secs_f64()).ok()))
|
||||||
});
|
});
|
||||||
reg.add_method("permissions", |_, me, ()| Ok(yazi_shared::permissions(me.permissions)));
|
reg.add_method("permissions", |_, me, ()| {
|
||||||
|
Ok(
|
||||||
|
#[cfg(unix)]
|
||||||
|
Some(yazi_shared::permissions(me.permissions)),
|
||||||
|
#[cfg(windows)]
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
// Extension
|
// Extension
|
||||||
reg.add_field_method_get("name", |_, me| {
|
reg.add_field_method_get("name", |_, me| {
|
||||||
|
|
|
||||||
|
|
@ -91,15 +91,10 @@ pub fn copy_with_progress(from: &Path, to: &Path) -> mpsc::Receiver<Result<u64,
|
||||||
rx
|
rx
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert a file mode to a string representation
|
|
||||||
#[cfg(windows)]
|
|
||||||
#[allow(clippy::collapsible_else_if)]
|
|
||||||
pub fn permissions(_: u32) -> Option<String> { None }
|
|
||||||
|
|
||||||
// Convert a file mode to a string representation
|
// Convert a file mode to a string representation
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[allow(clippy::collapsible_else_if)]
|
#[allow(clippy::collapsible_else_if)]
|
||||||
pub fn permissions(mode: u32) -> Option<String> {
|
pub fn permissions(mode: u32) -> String {
|
||||||
use libc::{mode_t, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR};
|
use libc::{mode_t, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR};
|
||||||
|
|
||||||
let mut s = String::with_capacity(10);
|
let mut s = String::with_capacity(10);
|
||||||
|
|
@ -143,7 +138,7 @@ pub fn permissions(mode: u32) -> Option<String> {
|
||||||
if m & S_ISVTX != 0 { 'T' } else { '-' }
|
if m & S_ISVTX != 0 { 'T' } else { '-' }
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(s)
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the max common root of a list of files
|
// Find the max common root of a list of files
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue