diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 2 | ||||
| -rw-r--r-- | src/libstd/fs.rs | 21 | ||||
| -rw-r--r-- | src/libstd/io/prelude.rs | 1 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 3 | ||||
| -rw-r--r-- | src/libstd/path.rs | 79 | ||||
| -rw-r--r-- | src/libstd/sync/condvar.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sys/common/unwind/mod.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/fs.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/thread.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/windows/backtrace.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/printing/gnu.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/printing/msvc.rs | 2 |
13 files changed, 117 insertions, 19 deletions
diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 5629cba1e0b..684a3005606 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -16,7 +16,9 @@ reason = "API has not been scrutinized and is highly likely to \ either disappear or change", issue = "27810")] +#![deprecated(since = "1.5.0", reason = "replaced with crates.io crates")] #![allow(missing_docs)] +#![allow(deprecated)] use prelude::v1::*; diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 1da7a1502d9..6178f1bbb8e 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -955,8 +955,21 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> { /// Returns the canonical form of a path with all intermediate components /// normalized and symbolic links resolved. -#[unstable(feature = "fs_canonicalize", reason = "recently added API", - issue = "27706")] +/// +/// This function may return an error in situations like where the path does not +/// exist, a component in the path is not a directory, or an I/O error happens. +/// +/// # Examples +/// +/// ``` +/// use std::fs; +/// +/// # fn foo() -> std::io::Result<()> { +/// let path = try!(fs::canonicalize("../a/../foo.txt")); +/// # Ok(()) +/// # } +/// ``` +#[stable(feature = "fs_canonicalize", since = "1.5.0")] pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> { fs_imp::canonicalize(path.as_ref()) } @@ -1158,11 +1171,12 @@ impl Iterator for WalkDir { } /// Utility methods for paths. -#[unstable(feature = "path_ext", +#[unstable(feature = "path_ext_deprecated", reason = "The precise set of methods exposed on this trait may \ change and some methods may be removed. For stable code, \ see the std::fs::metadata function.", issue = "27725")] +#[deprecated(since = "1.5.0", reason = "replaced with inherent methods")] pub trait PathExt { /// Gets information on the file, directory, etc at this path. /// @@ -1215,6 +1229,7 @@ pub trait PathExt { fn is_dir(&self) -> bool; } +#[allow(deprecated)] impl PathExt for Path { fn metadata(&self) -> io::Result<Metadata> { metadata(self) } fn symlink_metadata(&self) -> io::Result<Metadata> { symlink_metadata(self) } diff --git a/src/libstd/io/prelude.rs b/src/libstd/io/prelude.rs index db5c1da8a42..f8fbe485c9b 100644 --- a/src/libstd/io/prelude.rs +++ b/src/libstd/io/prelude.rs @@ -21,4 +21,5 @@ #![stable(feature = "rust1", since = "1.0.0")] pub use super::{Read, Write, BufRead, Seek}; +#[allow(deprecated)] pub use fs::PathExt; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index a624b352126..93d1ce168b7 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -210,7 +210,6 @@ #![feature(borrow_state)] #![feature(box_syntax)] #![feature(cfg_target_vendor)] -#![feature(char_from_unchecked)] #![feature(char_internals)] #![feature(clone_from_slice)] #![feature(collections)] @@ -225,7 +224,6 @@ #![feature(heap_api)] #![feature(int_error_internals)] #![feature(into_cow)] -#![feature(iter_order)] #![feature(lang_items)] #![feature(libc)] #![feature(linkage, thread_local, asm)] @@ -251,7 +249,6 @@ #![feature(decode_utf16)] #![feature(unwind_attributes)] #![feature(vec_push_all)] -#![feature(vec_resize)] #![feature(wrapping)] #![feature(zero_one)] #![cfg_attr(windows, feature(str_utf16))] diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 43c2766782e..fe12b671235 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -101,12 +101,14 @@ use ascii::*; use borrow::{Borrow, IntoCow, ToOwned, Cow}; use cmp; +use fmt; +use fs; +use io; use iter; use mem; use ops::{self, Deref}; use string::String; use vec::Vec; -use fmt; use ffi::{OsStr, OsString}; @@ -1689,6 +1691,81 @@ impl Path { pub fn display(&self) -> Display { Display { path: self } } + + + /// Gets information on the file, directory, etc at this path. + /// + /// Consult the `fs::metadata` documentation for more info. + /// + /// This call preserves identical runtime/error semantics with + /// `fs::metadata`. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn metadata(&self) -> io::Result<fs::Metadata> { + fs::metadata(self) + } + + /// Gets information on the file, directory, etc at this path. + /// + /// Consult the `fs::symlink_metadata` documentation for more info. + /// + /// This call preserves identical runtime/error semantics with + /// `fs::symlink_metadata`. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn symlink_metadata(&self) -> io::Result<fs::Metadata> { + fs::symlink_metadata(self) + } + + /// Returns the canonical form of a path, normalizing all components and + /// eliminate all symlinks. + /// + /// This call preserves identical runtime/error semantics with + /// `fs::canonicalize`. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn canonicalize(&self) -> io::Result<PathBuf> { + fs::canonicalize(self) + } + + /// Reads the symlink at this path. + /// + /// For more information see `fs::read_link`. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn read_link(&self) -> io::Result<PathBuf> { + fs::read_link(self) + } + + /// Reads the directory at this path. + /// + /// For more information see `fs::read_dir`. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn read_dir(&self) -> io::Result<fs::ReadDir> { + fs::read_dir(self) + } + + /// Boolean value indicator whether the underlying file exists on the local + /// filesystem. Returns false in exactly the cases where `fs::stat` fails. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn exists(&self) -> bool { + fs::metadata(self).is_ok() + } + + /// Whether the underlying implementation (be it a file path, or something + /// else) points at a "regular file" on the FS. Will return false for paths + /// to non-existent locations or directories or other non-regular files + /// (named pipes, etc). Follows links when making this determination. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn is_file(&self) -> bool { + fs::metadata(self).map(|m| m.is_file()).unwrap_or(false) + } + + /// Whether the underlying implementation (be it a file path, or something + /// else) is pointing at a directory in the underlying FS. Will return + /// false for paths to non-existent locations or if the item is not a + /// directory (eg files, named pipes, etc). Follows links when making this + /// determination. + #[stable(feature = "path_ext", since = "1.5.0")] + pub fn is_dir(&self) -> bool { + fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false) + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 851726d91c6..1b32515e9f7 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -21,12 +21,12 @@ use time::Duration; /// A type indicating whether a timed wait on a condition variable returned /// due to a time out or not. #[derive(Debug, PartialEq, Eq, Copy, Clone)] -#[unstable(feature = "wait_timeout", reason = "newly added", issue = "27772")] +#[stable(feature = "wait_timeout", since = "1.5.0")] pub struct WaitTimeoutResult(bool); impl WaitTimeoutResult { /// Returns whether the wait was known to have timed out. - #[unstable(feature = "wait_timeout", reason = "newly added", issue = "27772")] + #[stable(feature = "wait_timeout", since = "1.5.0")] pub fn timed_out(&self) -> bool { self.0 } @@ -189,8 +189,7 @@ impl Condvar { /// /// Like `wait`, the lock specified will be re-acquired when this function /// returns, regardless of whether the timeout elapsed or not. - #[unstable(feature = "wait_timeout", reason = "waiting for Duration", - issue = "27772")] + #[stable(feature = "wait_timeout", since = "1.5.0")] pub fn wait_timeout<'a, T>(&self, guard: MutexGuard<'a, T>, dur: Duration) -> LockResult<(MutexGuard<'a, T>, WaitTimeoutResult)> { diff --git a/src/libstd/sys/common/unwind/mod.rs b/src/libstd/sys/common/unwind/mod.rs index 3978aeb39bc..d87ab56d4e1 100644 --- a/src/libstd/sys/common/unwind/mod.rs +++ b/src/libstd/sys/common/unwind/mod.rs @@ -81,12 +81,12 @@ use sys_common::mutex::Mutex; #[path = "seh.rs"] #[doc(hidden)] pub mod imp; -// SNAP: i686-pc-windows-gnu +// stage0: i686-pc-windows-gnu #[cfg(all(stage0, windows, target_arch = "x86_64", target_env = "gnu"))] #[path = "seh64_gnu.rs"] #[doc(hidden)] pub mod imp; -// SNAP: x86_64-pc-windows-msvc +// stage0: x86_64-pc-windows-msvc #[cfg(all(stage0, windows, target_arch = "x86_64", target_env = "msvc"))] #[path = "seh.rs"] #[doc(hidden)] pub mod imp; diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index 46ab83199f0..5ef37ae51c9 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -178,21 +178,23 @@ impl MetadataExt for fs::Metadata { } /// Add special unix types (block/char device, fifo and socket) -#[unstable(feature = "file_type_ext", reason = "recently added API", - issue = "27796")] +#[stable(feature = "file_type_ext", since = "1.5.0")] pub trait FileTypeExt { /// Returns whether this file type is a block device. + #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_block_device(&self) -> bool; /// Returns whether this file type is a char device. + #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_char_device(&self) -> bool; /// Returns whether this file type is a fifo. + #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_fifo(&self) -> bool; /// Returns whether this file type is a socket. + #[stable(feature = "file_type_ext", since = "1.5.0")] fn is_socket(&self) -> bool; } -#[unstable(feature = "file_type_ext", reason = "recently added API", - issue = "27796")] +#[stable(feature = "file_type_ext", since = "1.5.0")] impl FileTypeExt for fs::FileType { fn is_block_device(&self) -> bool { self.as_inner().is(libc::S_IFBLK) } fn is_char_device(&self) -> bool { self.as_inner().is(libc::S_IFCHR) } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index d0c027ddad6..c2145ac875a 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -543,7 +543,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> { } pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { - use fs::{File, PathExt, set_permissions}; + use fs::{File, set_permissions}; if !from.is_file() { return Err(Error::new(ErrorKind::InvalidInput, "the source path is not an existing regular file")) diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 50e01ecf9fa..b7968e9344f 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -356,6 +356,7 @@ pub mod guard { // but that caused Debian to detect an unnecessarily strict versioned // dependency on libc6 (#23628). #[cfg(target_os = "linux")] +#[allow(deprecated)] fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize { use dynamic_lib::DynamicLibrary; use sync::Once; diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index 9534a107d16..b562e772b9c 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -22,7 +22,7 @@ //! copy of that function in my mingw install (maybe it was broken?). Instead, //! this takes the route of using StackWalk64 in order to walk the stack. -#![allow(dead_code)] +#![allow(dead_code, deprecated)] use io::prelude::*; diff --git a/src/libstd/sys/windows/printing/gnu.rs b/src/libstd/sys/windows/printing/gnu.rs index 8d3c93bb7b1..e27bef0b1e9 100644 --- a/src/libstd/sys/windows/printing/gnu.rs +++ b/src/libstd/sys/windows/printing/gnu.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(deprecated)] + use dynamic_lib::DynamicLibrary; use io; use io::prelude::*; diff --git a/src/libstd/sys/windows/printing/msvc.rs b/src/libstd/sys/windows/printing/msvc.rs index 81d19374fea..6f1db5df7db 100644 --- a/src/libstd/sys/windows/printing/msvc.rs +++ b/src/libstd/sys/windows/printing/msvc.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(deprecated)] + use sys_common::backtrace::{output, output_fileline}; use ffi::CStr; use dynamic_lib::DynamicLibrary; |
