1
Fork 0

Support setting file accessed/modified timestamps

Add `struct FileTimes` to contain the relevant file timestamps, since
most platforms require setting all of them at once. (This also allows
for future platform-specific extensions such as setting creation time.)

Add `File::set_file_time` to set the timestamps for a `File`.

Implement the `sys` backends for UNIX, macOS (which needs to fall back
to `futimes` before macOS 10.13 because it lacks `futimens`), Windows,
and WASI.
This commit is contained in:
Josh Triplett 2022-06-18 20:00:21 -07:00
parent 21e9336fe8
commit 61b45c670b
9 changed files with 222 additions and 2 deletions

View file

@ -38,7 +38,7 @@ use crate::error::Error;
use crate::fmt;
use crate::ops::{Add, AddAssign, Sub, SubAssign};
use crate::sys::time;
use crate::sys_common::FromInner;
use crate::sys_common::{FromInner, IntoInner};
#[stable(feature = "time", since = "1.3.0")]
pub use core::time::Duration;
@ -686,3 +686,9 @@ impl FromInner<time::SystemTime> for SystemTime {
SystemTime(time)
}
}
impl IntoInner<time::SystemTime> for SystemTime {
fn into_inner(self) -> time::SystemTime {
self.0
}
}