From ec68c4a8351e65ec6e2d349aa103a457494ad814 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 27 May 2015 16:29:55 -0700 Subject: std: Stabilize a number of new fs features This commit stabilizes the following APIs, slating them all to be cherry-picked into the 1.1 release. * fs::FileType (and transitively the derived trait implementations) * fs::Metadata::file_type * fs::FileType::is_dir * fs::FileType::is_file * fs::FileType::is_symlink * fs::DirEntry::metadata * fs::DirEntry::file_type * fs::DirEntry::file_name * fs::set_permissions * fs::symlink_metadata * os::raw::{self, *} * os::{android, bitrig, linux, ...}::raw::{self, *} * os::{android, bitrig, linux, ...}::fs::MetadataExt * os::{android, bitrig, linux, ...}::fs::MetadataExt::as_raw_stat * os::unix::fs::PermissionsExt * os::unix::fs::PermissionsExt::mode * os::unix::fs::PermissionsExt::set_mode * os::unix::fs::PermissionsExt::from_mode * os::unix::fs::OpenOptionsExt * os::unix::fs::OpenOptionsExt::mode * os::unix::fs::DirEntryExt * os::unix::fs::DirEntryExt::ino * os::windows::fs::MetadataExt * os::windows::fs::MetadataExt::file_attributes * os::windows::fs::MetadataExt::creation_time * os::windows::fs::MetadataExt::last_access_time * os::windows::fs::MetadataExt::last_write_time * os::windows::fs::MetadataExt::file_size The `os::unix::fs::Metadata` structure was also removed entirely, moving all of its associated methods into the `os::unix::fs::MetadataExt` trait instead. The methods are all marked as `#[stable]` still. As some minor cleanup, some deprecated and unstable fs apis were also removed: * File::path * Metadata::accessed * Metadata::modified Features that were explicitly left unstable include: * fs::WalkDir - the semantics of this were not considered in the recent fs expansion RFC. * fs::DirBuilder - it's still not 100% clear if the naming is right here and if the set of functionality exposed is appropriate. * fs::canonicalize - the implementation on Windows here is specifically in question as it always returns a verbatim path. Additionally the Unix implementation is susceptible to buffer overflows on long paths unfortunately. * fs::PathExt - as this is just a convenience trait, it is not stabilized at this time. * fs::set_file_times - this funciton is still waiting on a time abstraction. --- src/libstd/sys/windows/ext/fs.rs | 11 +++++++++-- src/libstd/sys/windows/ext/raw.rs | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/libstd/sys/windows') diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index aaffe8dadf8..cad92d33fbc 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -21,7 +21,8 @@ use sys; use sys_common::{AsInnerMut, AsInner}; /// Windows-specific extensions to `OpenOptions` -#[unstable(feature = "fs_ext", reason = "may require more thought/methods")] +#[unstable(feature = "open_options_ext", + reason = "may require more thought/methods")] pub trait OpenOptionsExt { /// Overrides the `dwDesiredAccess` argument to the call to `CreateFile` /// with the specified value. @@ -66,39 +67,45 @@ impl OpenOptionsExt for OpenOptions { /// Extension methods for `fs::Metadata` to access the raw fields contained /// within. -#[unstable(feature = "metadata_ext", reason = "recently added API")] +#[stable(feature = "metadata_ext", since = "1.1.0")] pub trait MetadataExt { /// Returns the value of the `dwFileAttributes` field of this metadata. /// /// This field contains the file system attribute information for a file /// or directory. + #[stable(feature = "metadata_ext", since = "1.1.0")] fn file_attributes(&self) -> u32; /// Returns the value of the `ftCreationTime` field of this metadata. /// /// The returned 64-bit value represents the number of 100-nanosecond /// intervals since January 1, 1601 (UTC). + #[stable(feature = "metadata_ext", since = "1.1.0")] fn creation_time(&self) -> u64; /// Returns the value of the `ftLastAccessTime` field of this metadata. /// /// The returned 64-bit value represents the number of 100-nanosecond /// intervals since January 1, 1601 (UTC). + #[stable(feature = "metadata_ext", since = "1.1.0")] fn last_access_time(&self) -> u64; /// Returns the value of the `ftLastWriteTime` field of this metadata. /// /// The returned 64-bit value represents the number of 100-nanosecond /// intervals since January 1, 1601 (UTC). + #[stable(feature = "metadata_ext", since = "1.1.0")] fn last_write_time(&self) -> u64; /// Returns the value of the `nFileSize{High,Low}` fields of this /// metadata. /// /// The returned value does not have meaning for directories. + #[stable(feature = "metadata_ext", since = "1.1.0")] fn file_size(&self) -> u64; } +#[stable(feature = "metadata_ext", since = "1.1.0")] impl MetadataExt for Metadata { fn file_attributes(&self) -> u32 { self.as_inner().attrs() } fn creation_time(&self) -> u64 { self.as_inner().created() } diff --git a/src/libstd/sys/windows/ext/raw.rs b/src/libstd/sys/windows/ext/raw.rs index 656e480ad09..e1796d4b5f0 100644 --- a/src/libstd/sys/windows/ext/raw.rs +++ b/src/libstd/sys/windows/ext/raw.rs @@ -10,12 +10,12 @@ //! Windows-specific primitives -#![unstable(feature = "raw_ext", reason = "recently added API")] +#[stable(feature = "raw_ext", since = "1.1.0")] -use os::raw; +use os::raw::c_void; -pub type HANDLE = *mut raw::c_void; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type HANDLE = *mut c_void; #[cfg(target_pointer_width = "32")] -pub type SOCKET = u32; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type SOCKET = u32; #[cfg(target_pointer_width = "64")] -pub type SOCKET = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type SOCKET = u64; -- cgit 1.4.1-3-g733a5