-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscenario_file_timestamps.rs
50 lines (44 loc) · 1.49 KB
/
scenario_file_timestamps.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use std::fs;
use std::sync;
use std::time;
macro_rules! initialize {
($relative_path:literal, $absolute_path:literal) => {
Asset {
creation_time: sync::LazyLock::new(|| {
fs::metadata($absolute_path)
.and_then(|metadata| metadata.created())
.ok()
}),
last_access_time: sync::LazyLock::new(|| {
fs::metadata($absolute_path)
.and_then(|metadata| metadata.accessed())
.ok()
}),
last_modification_time: sync::LazyLock::new(|| {
fs::metadata($absolute_path)
.and_then(|metadata| metadata.modified())
.ok()
}),
}
};
}
#[iftree::include_file_tree(
"
paths = '/examples/assets/**'
template.initializer = 'initialize'
"
)]
pub struct Asset {
creation_time: sync::LazyLock<Option<time::SystemTime>>,
last_access_time: sync::LazyLock<Option<time::SystemTime>>,
last_modification_time: sync::LazyLock<Option<time::SystemTime>>,
}
fn main() {
use base::examples::assets;
let creation_time = *assets::CREDITS_MD.creation_time;
println!("Creation time: {creation_time:?}");
let last_access_time = *assets::CREDITS_MD.last_access_time;
println!("Last access time: {last_access_time:?}");
let last_modification_time = *assets::CREDITS_MD.last_modification_time;
println!("Last modification time: {last_modification_time:?}");
}