libmft2bodyfile/intern/
timestamp_tuple.rs1
2use mft::attribute::x10::StandardInfoAttr;
3use mft::attribute::x30::FileNameAttr;
4use chrono::{DateTime, Utc};
5use std::cmp;
6
7pub struct TimestampTuple {
8 accessed: i64,
9 mft_modified: i64,
10 modified: i64,
11 created: i64,
12}
13
14impl TimestampTuple {
15 fn win32_to_unix_timestamp(win32_ts: &DateTime<Utc>) -> i64 {
16 cmp::max(0, win32_ts.timestamp())
18 }
19}
20
21impl From<&FileNameAttr> for TimestampTuple {
22 fn from(attr: &FileNameAttr) -> TimestampTuple {
23 TimestampTuple {
24 accessed: Self::win32_to_unix_timestamp(&attr.accessed),
25 mft_modified: Self::win32_to_unix_timestamp(&attr.mft_modified),
26 modified: Self::win32_to_unix_timestamp(&attr.modified),
27 created: Self::win32_to_unix_timestamp(&attr.created)
28 }
29 }
30}
31
32
33impl From<&StandardInfoAttr> for TimestampTuple {
34 fn from(attr: &StandardInfoAttr) -> TimestampTuple {
35 TimestampTuple {
36 accessed: Self::win32_to_unix_timestamp(&attr.accessed),
37 mft_modified: Self::win32_to_unix_timestamp(&attr.mft_modified),
38 modified: Self::win32_to_unix_timestamp(&attr.modified),
39 created: Self::win32_to_unix_timestamp(&attr.created)
40 }
41 }
42}
43
44impl TimestampTuple {
45 pub fn accessed(&self) -> i64 {self.accessed}
46 pub fn mft_modified(&self) -> i64 {self.mft_modified}
47 pub fn modified(&self) -> i64 {self.modified}
48 pub fn created(&self) -> i64 {self.created}
49}