Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize file_set_times #117422

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub struct OpenOptions(fs_imp::OpenOptions);

/// Representation of the various timestamps on a file.
#[derive(Copy, Clone, Debug, Default)]
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub struct FileTimes(fs_imp::FileTimes);

/// Representation of the various permissions on a file.
Expand Down Expand Up @@ -676,8 +676,6 @@ impl File {
/// # Examples
///
/// ```no_run
/// #![feature(file_set_times)]
///
/// fn main() -> std::io::Result<()> {
/// use std::fs::{self, File, FileTimes};
///
Expand All @@ -690,7 +688,7 @@ impl File {
/// Ok(())
/// }
/// ```
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
#[doc(alias = "futimens")]
#[doc(alias = "futimes")]
#[doc(alias = "SetFileTime")]
Expand All @@ -701,7 +699,7 @@ impl File {
/// Changes the modification time of the underlying file.
///
/// This is an alias for `set_times(FileTimes::new().set_modified(time))`.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn set_modified(&self, time: SystemTime) -> io::Result<()> {
self.set_times(FileTimes::new().set_modified(time))
Expand Down Expand Up @@ -1415,20 +1413,20 @@ impl FileTimes {
/// Create a new `FileTimes` with no times set.
///
/// Using the resulting `FileTimes` in [`File::set_times`] will not modify any timestamps.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub fn new() -> Self {
Self::default()
}

/// Set the last access time of a file.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub fn set_accessed(mut self, t: SystemTime) -> Self {
self.0.set_accessed(t.into_inner());
self
}

/// Set the last modified time of a file.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub fn set_modified(mut self, t: SystemTime) -> Self {
self.0.set_modified(t.into_inner());
self
Expand All @@ -1442,7 +1440,7 @@ impl AsInnerMut<fs_imp::FileTimes> for FileTimes {
}

// For implementing OS extension traits in `std::os`
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
impl Sealed for FileTimes {}

impl Permissions {
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/os/ios/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ impl MetadataExt for Metadata {
}

/// OS-specific extensions to [`fs::FileTimes`].
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub trait FileTimesExt: Sealed {
/// Set the creation time of a file.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
fn set_created(self, t: SystemTime) -> Self;
}

#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
impl FileTimesExt for fs::FileTimes {
fn set_created(mut self, t: SystemTime) -> Self {
self.as_inner_mut().set_created(t.into_inner());
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/os/macos/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ impl MetadataExt for Metadata {
}

/// OS-specific extensions to [`fs::FileTimes`].
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub trait FileTimesExt: Sealed {
/// Set the creation time of a file.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
fn set_created(self, t: SystemTime) -> Self;
}

#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
impl FileTimesExt for fs::FileTimes {
fn set_created(mut self, t: SystemTime) -> Self {
self.as_inner_mut().set_created(t.into_inner());
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/os/watchos/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ impl MetadataExt for Metadata {
}

/// OS-specific extensions to [`fs::FileTimes`].
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub trait FileTimesExt: Sealed {
/// Set the creation time of a file.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
fn set_created(self, t: SystemTime) -> Self;
}

#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
impl FileTimesExt for fs::FileTimes {
fn set_created(mut self, t: SystemTime) -> Self {
self.as_inner_mut().set_created(t.into_inner());
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/os/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,14 @@ impl FileTypeExt for fs::FileType {
}

/// Windows-specific extensions to [`fs::FileTimes`].
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
pub trait FileTimesExt: Sealed {
/// Set the creation time of a file.
#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
fn set_created(self, t: SystemTime) -> Self;
}

#[unstable(feature = "file_set_times", issue = "98245")]
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
impl FileTimesExt for fs::FileTimes {
fn set_created(mut self, t: SystemTime) -> Self {
self.as_inner_mut().set_created(t.into_inner());
Expand Down
Loading