diff options
| author | Josh Triplett <josh@joshtriplett.org> | 2022-06-18 20:00:21 -0700 |
|---|---|---|
| committer | Josh Triplett <josh@joshtriplett.org> | 2022-07-15 02:54:06 -0700 |
| commit | 61b45c670bc6a9c0d7d35769ed58899f347a6371 (patch) | |
| tree | 966bb1912f78dded9499f0eef0fbde2a45cd7ee8 /library/std/src/time.rs | |
| parent | 21e9336fe81a1fce364349bb7a35a0347c369f34 (diff) | |
| download | rust-61b45c670bc6a9c0d7d35769ed58899f347a6371.tar.gz rust-61b45c670bc6a9c0d7d35769ed58899f347a6371.zip | |
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.
Diffstat (limited to 'library/std/src/time.rs')
| -rw-r--r-- | library/std/src/time.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/time.rs b/library/std/src/time.rs index b2014f462bd..759a59e1f98 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -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 + } +} |
