diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-28 16:29:44 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-28 17:03:45 +0200 |
commit | 2583b50e2a49fb0492ae0d341a51353b806c3233 (patch) | |
tree | 440f691dbf74da7fb17f7deaed9f43e130391787 /src/lib.rs | |
parent | 8fae3c648d81d75510ecb68ed80d0042a5a2088f (diff) | |
download | summain-rs-2583b50e2a49fb0492ae0d341a51353b806c3233.tar.gz |
feat! ManifestEntry::new now looks up metadata itself
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -32,7 +32,7 @@ //! ~~~ use serde::Serialize; -use std::fs::Metadata; +use std::fs::symlink_metadata; use std::os::linux::fs::MetadataExt; use std::path::{Path, PathBuf}; @@ -57,8 +57,9 @@ impl ManifestEntry { /// caller. This function doesn't query the system for it. /// /// The structure can be serialized using serde. - pub fn new(path: &Path, m: Metadata) -> Self { - Self { + pub fn new(path: &Path) -> std::io::Result<Self> { + let m = symlink_metadata(path)?; + Ok(Self { path: path.to_path_buf(), atime: m.st_atime(), atime_nsec: m.st_atime_nsec(), @@ -67,7 +68,7 @@ impl ManifestEntry { mtime_nsec: m.st_mtime_nsec(), nlink: m.st_nlink(), size: if m.is_dir() { None } else { Some(m.st_size()) }, - } + }) } } |