diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-05 14:27:08 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-05 14:27:08 -0400 |
commit | 530973aea3fa46c469541bc291513a75e3aacd3e (patch) | |
tree | d31a6676038c7d7d6bba9a7feefadd71cebc0ecd /src/io | |
parent | 8799211cf9e7547416618725a86463444ed9e342 (diff) |
add support for displaying owner and group of files
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/metadata.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/io/metadata.rs b/src/io/metadata.rs index 5405512..341e8f2 100644 --- a/src/io/metadata.rs +++ b/src/io/metadata.rs @@ -6,22 +6,37 @@ pub struct JoshutoMetadata { pub modified: time::SystemTime, pub permissions: fs::Permissions, pub file_type: fs::FileType, + #[cfg(unix)] + pub uid: u32, + #[cfg(unix)] + pub gid: u32, } impl JoshutoMetadata { pub fn from(path: &path::Path) -> Result<Self, io::Error> { + #[cfg(unix)] + use std::os::unix::fs::MetadataExt; + let metadata = fs::symlink_metadata(path)?; let len = metadata.len(); let modified = metadata.modified()?; let permissions = metadata.permissions(); let file_type = metadata.file_type(); + #[cfg(unix)] + let uid = metadata.uid(); + #[cfg(unix)] + let gid = metadata.gid(); Ok(JoshutoMetadata { len, modified, permissions, file_type, + #[cfg(unix)] + uid, + #[cfg(unix)] + gid, }) } } |