summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-11 19:13:55 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-11 19:13:55 +0200
commit01b9765db0feb3f1f36eec4d71489ccbaa6496b5 (patch)
treed188d5b658380c0e558f070b6268b7ee50b20da1 /src
parent02028a3239f45ada950e43a9fb34e23c6a8ccbed (diff)
downloadobnam2-01b9765db0feb3f1f36eec4d71489ccbaa6496b5.tar.gz
add timestamps to fsentry
Diffstat (limited to 'src')
-rw-r--r--src/fsentry.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/fsentry.rs b/src/fsentry.rs
index 7adf610..aae1475 100644
--- a/src/fsentry.rs
+++ b/src/fsentry.rs
@@ -22,20 +22,27 @@ pub struct FilesystemEntry {
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
// However, it's 32 bits on Linux, so that's what we store.
mode: u32,
+
+ // Linux can store file system time stamps in nanosecond
+ // resolution. We store them as two 64-bit integers.
+ mtime: i64,
+ mtime_ns: i64,
+ atime: i64,
+ atime_ns: i64,
}
#[allow(clippy::len_without_is_empty)]
impl FilesystemEntry {
pub fn from_metadata(path: &Path, meta: &Metadata) -> Self {
- let path = path.to_path_buf();
- let kind = FilesystemKind::from_file_type(meta.file_type());
- let len = meta.len();
- let mode = meta.st_mode();
Self {
- path,
- kind,
- len,
- mode,
+ path: path.to_path_buf(),
+ kind: FilesystemKind::from_file_type(meta.file_type()),
+ len: meta.len(),
+ mode: meta.st_mode(),
+ mtime: meta.st_mtime(),
+ mtime_ns: meta.st_mtime_nsec(),
+ atime: meta.st_atime(),
+ atime_ns: meta.st_atime_nsec(),
}
}