From 6b17c9e2780d9d0827471b0e87a3a1acce22b0aa Mon Sep 17 00:00:00 2001 From: Lauri Niskanen Date: Tue, 9 Jul 2024 01:35:37 +0300 Subject: [PATCH] Provide nlink metadata for plugins --- yazi-plugin/src/cha/cha.rs | 3 +++ yazi-shared/src/fs/cha.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/yazi-plugin/src/cha/cha.rs b/yazi-plugin/src/cha/cha.rs index af3e4813..96830bee 100644 --- a/yazi-plugin/src/cha/cha.rs +++ b/yazi-plugin/src/cha/cha.rs @@ -27,6 +27,7 @@ impl Cha { { reg.add_field_method_get("uid", |_, me| Ok(me.uid)); reg.add_field_method_get("gid", |_, me| Ok(me.gid)); + reg.add_field_method_get("nlink", |_, me| Ok(me.nlink)); } reg.add_field_method_get("length", |_, me| Ok(me.len)); @@ -80,6 +81,8 @@ impl Cha { uid: t.raw_get("uid").unwrap_or_default(), #[cfg(unix)] gid: t.raw_get("gid").unwrap_or_default(), + #[cfg(unix)] + nlink: t.raw_get("nlink").unwrap_or_default(), }) })?, ) diff --git a/yazi-shared/src/fs/cha.rs b/yazi-shared/src/fs/cha.rs index 4e364afb..1eae75f3 100644 --- a/yazi-shared/src/fs/cha.rs +++ b/yazi-shared/src/fs/cha.rs @@ -31,6 +31,8 @@ pub struct Cha { pub uid: u32, #[cfg(unix)] pub gid: u32, + #[cfg(unix)] + pub nlink: u64, } impl From for Cha { @@ -79,6 +81,11 @@ impl From for Cha { use std::os::unix::fs::MetadataExt; m.gid() }, + #[cfg(unix)] + nlink: { + use std::os::unix::fs::MetadataExt; + m.nlink() + }, } } }