Skip to content

Commit

Permalink
aix, nto, hurd: Implement impl StatExt
Browse files Browse the repository at this point in the history
  • Loading branch information
sthibaul committed May 26, 2024
1 parent dfb0552 commit 1829605
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub use std::os::wasi::fs::{DirEntryExt, FileExt, FileTypeExt, MetadataExt, Open
/// the Unix epoch. Until the next semver bump, these unsigned fields are
/// deprecated, and this trait provides accessors which return their values
/// as signed integers.
#[cfg(all(unix, not(any(target_os = "aix", target_os = "nto"))))]
#[cfg(all(unix)))]
pub trait StatExt {
/// Return the value of the `st_atime` field, casted to the correct type.
fn atime(&self) -> i64;
Expand Down Expand Up @@ -181,3 +181,22 @@ impl StatExt for Stat {
self.st_ctime as i64
}
}

#[cfg(any(target_os = "aix", target_os = "hurd", target_os = "nto"))]
#[allow(deprecated)]
impl StatExt for Stat {
#[inline]
fn atime(&self) -> i64 {
self.st_atim.tv_sec as i64
}

#[inline]
fn mtime(&self) -> i64 {
self.st_mtim.tv_sec as i64
}

#[inline]
fn ctime(&self) -> i64 {
self.st_ctim.tv_sec as i64
}
}

0 comments on commit 1829605

Please sign in to comment.