Auto merge of #117422 - joshtriplett:stabilize-file-times, r=workingjubilee
Stabilize `file_set_times` Approved via FCP in https://github.com/rust-lang/rust/issues/98245 .
This commit is contained in:
commit
dd24c7bdbf
@ -189,7 +189,7 @@ pub struct OpenOptions(fs_imp::OpenOptions);
|
|||||||
|
|
||||||
/// Representation of the various timestamps on a file.
|
/// Representation of the various timestamps on a file.
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[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);
|
pub struct FileTimes(fs_imp::FileTimes);
|
||||||
|
|
||||||
/// Representation of the various permissions on a file.
|
/// Representation of the various permissions on a file.
|
||||||
@ -676,8 +676,6 @@ impl File {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(file_set_times)]
|
|
||||||
///
|
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() -> std::io::Result<()> {
|
||||||
/// use std::fs::{self, File, FileTimes};
|
/// use std::fs::{self, File, FileTimes};
|
||||||
///
|
///
|
||||||
@ -690,7 +688,7 @@ impl File {
|
|||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "file_set_times", issue = "98245")]
|
#[stable(feature = "file_set_times", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[doc(alias = "futimens")]
|
#[doc(alias = "futimens")]
|
||||||
#[doc(alias = "futimes")]
|
#[doc(alias = "futimes")]
|
||||||
#[doc(alias = "SetFileTime")]
|
#[doc(alias = "SetFileTime")]
|
||||||
@ -701,7 +699,7 @@ impl File {
|
|||||||
/// Changes the modification time of the underlying file.
|
/// Changes the modification time of the underlying file.
|
||||||
///
|
///
|
||||||
/// This is an alias for `set_times(FileTimes::new().set_modified(time))`.
|
/// 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]
|
#[inline]
|
||||||
pub fn set_modified(&self, time: SystemTime) -> io::Result<()> {
|
pub fn set_modified(&self, time: SystemTime) -> io::Result<()> {
|
||||||
self.set_times(FileTimes::new().set_modified(time))
|
self.set_times(FileTimes::new().set_modified(time))
|
||||||
@ -1415,20 +1413,20 @@ impl FileTimes {
|
|||||||
/// Create a new `FileTimes` with no times set.
|
/// Create a new `FileTimes` with no times set.
|
||||||
///
|
///
|
||||||
/// Using the resulting `FileTimes` in [`File::set_times`] will not modify any timestamps.
|
/// 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 {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the last access time of a file.
|
/// 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 {
|
pub fn set_accessed(mut self, t: SystemTime) -> Self {
|
||||||
self.0.set_accessed(t.into_inner());
|
self.0.set_accessed(t.into_inner());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the last modified time of a file.
|
/// 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 {
|
pub fn set_modified(mut self, t: SystemTime) -> Self {
|
||||||
self.0.set_modified(t.into_inner());
|
self.0.set_modified(t.into_inner());
|
||||||
self
|
self
|
||||||
@ -1442,7 +1440,7 @@ impl AsInnerMut<fs_imp::FileTimes> for FileTimes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For implementing OS extension traits in `std::os`
|
// 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 Sealed for FileTimes {}
|
||||||
|
|
||||||
impl Permissions {
|
impl Permissions {
|
||||||
|
@ -144,14 +144,14 @@ impl MetadataExt for Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// OS-specific extensions to [`fs::FileTimes`].
|
/// 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 {
|
pub trait FileTimesExt: Sealed {
|
||||||
/// Set the creation time of a file.
|
/// 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;
|
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 {
|
impl FileTimesExt for fs::FileTimes {
|
||||||
fn set_created(mut self, t: SystemTime) -> Self {
|
fn set_created(mut self, t: SystemTime) -> Self {
|
||||||
self.as_inner_mut().set_created(t.into_inner());
|
self.as_inner_mut().set_created(t.into_inner());
|
||||||
|
@ -150,14 +150,14 @@ impl MetadataExt for Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// OS-specific extensions to [`fs::FileTimes`].
|
/// 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 {
|
pub trait FileTimesExt: Sealed {
|
||||||
/// Set the creation time of a file.
|
/// 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;
|
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 {
|
impl FileTimesExt for fs::FileTimes {
|
||||||
fn set_created(mut self, t: SystemTime) -> Self {
|
fn set_created(mut self, t: SystemTime) -> Self {
|
||||||
self.as_inner_mut().set_created(t.into_inner());
|
self.as_inner_mut().set_created(t.into_inner());
|
||||||
|
@ -144,14 +144,14 @@ impl MetadataExt for Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// OS-specific extensions to [`fs::FileTimes`].
|
/// 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 {
|
pub trait FileTimesExt: Sealed {
|
||||||
/// Set the creation time of a file.
|
/// 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;
|
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 {
|
impl FileTimesExt for fs::FileTimes {
|
||||||
fn set_created(mut self, t: SystemTime) -> Self {
|
fn set_created(mut self, t: SystemTime) -> Self {
|
||||||
self.as_inner_mut().set_created(t.into_inner());
|
self.as_inner_mut().set_created(t.into_inner());
|
||||||
|
@ -528,14 +528,14 @@ impl FileTypeExt for fs::FileType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Windows-specific extensions to [`fs::FileTimes`].
|
/// 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 {
|
pub trait FileTimesExt: Sealed {
|
||||||
/// Set the creation time of a file.
|
/// 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;
|
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 {
|
impl FileTimesExt for fs::FileTimes {
|
||||||
fn set_created(mut self, t: SystemTime) -> Self {
|
fn set_created(mut self, t: SystemTime) -> Self {
|
||||||
self.as_inner_mut().set_created(t.into_inner());
|
self.as_inner_mut().set_created(t.into_inner());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user