rusht 1.3.0

Shell commands written in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use ::std::time::UNIX_EPOCH;

use ::async_std::fs;

pub async fn file_modified_time_in_seconds(path: &str) -> Option<u64> {
    match fs::metadata(path).await {
        Ok(meta) => Some(meta
            .modified()
            .unwrap_or_else(|_| panic!("could not get modified time for {path}"))
            .duration_since(UNIX_EPOCH)
            .unwrap_or_else(|_| panic!("could not get time difference for {path}"))
            .as_secs()),
        Err(_) => None
    }
}