diff options
Diffstat (limited to 'src/libstd/sys/windows')
| -rw-r--r-- | src/libstd/sys/windows/ext/fs.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sys/windows/ext/process.rs | 31 | ||||
| -rw-r--r-- | src/libstd/sys/windows/ext/raw.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/windows/fs.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/pipe.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process.rs | 22 |
6 files changed, 30 insertions, 48 deletions
diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index 28d9b3e0476..f629e983ce5 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/process.rs b/src/libstd/sys/windows/ext/process.rs index 0fd43a450f3..6f59be2687a 100644 --- a/src/libstd/sys/windows/ext/process.rs +++ b/src/libstd/sys/windows/ext/process.rs @@ -10,58 +10,43 @@ //! Extensions to `std::process` for Windows. -#![stable(feature = "from_raw_os", since = "1.1.0")] +#![stable(feature = "process_extensions", since = "1.2.0")] use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle}; use process; use sys; use sys_common::{AsInner, FromInner}; -#[stable(feature = "from_raw_os", since = "1.1.0")] +#[stable(feature = "process_extensions", since = "1.2.0")] impl FromRawHandle for process::Stdio { - /// Creates a new instance of `Stdio` from the raw underlying handle. - /// - /// When this `Stdio` is used as an I/O handle for a child process the given - /// handle will be duplicated via `DuplicateHandle` to ensure that the - /// handle has the correct permissions to cross the process boundary. - /// - /// Note that this function **does not** take ownership of the handle - /// provided and it will **not** be closed when `Stdio` goes out of scope. - /// As a result this method is unsafe because due to the lack of knowledge - /// about the lifetime of the provided handle, this could cause another I/O - /// primitive's ownership property of its handle to be violated. - /// - /// Also note that this handle may be used multiple times to spawn - /// processes. For example the `Command::spawn` function could be called - /// more than once to spawn more than one process sharing this handle. unsafe fn from_raw_handle(handle: RawHandle) -> process::Stdio { - let handle = sys::handle::RawHandle::new(handle as *mut _); - process::Stdio::from_inner(sys::process::Stdio::Handle(handle)) + let handle = sys::handle::Handle::new(handle as *mut _); + process::Stdio::from_inner(handle) } } -#[stable(feature = "from_raw_os", since = "1.1.0")] +#[stable(feature = "process_extensions", since = "1.2.0")] impl AsRawHandle for process::Child { fn as_raw_handle(&self) -> RawHandle { self.as_inner().handle().raw() as *mut _ } } -#[stable(feature = "from_raw_os", since = "1.1.0")] +#[stable(feature = "process_extensions", since = "1.2.0")] impl AsRawHandle for process::ChildStdin { fn as_raw_handle(&self) -> RawHandle { self.as_inner().handle().raw() as *mut _ } } -#[stable(feature = "from_raw_os", since = "1.1.0")] +#[stable(feature = "process_extensions", since = "1.2.0")] impl AsRawHandle for process::ChildStdout { fn as_raw_handle(&self) -> RawHandle { self.as_inner().handle().raw() as *mut _ } } -#[stable(feature = "from_raw_os", since = "1.1.0")] +#[stable(feature = "process_extensions", since = "1.2.0")] impl AsRawHandle for process::ChildStderr { fn as_raw_handle(&self) -> RawHandle { self.as_inner().handle().raw() as *mut _ 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; diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 4401a52d71f..437b2cc6491 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -368,7 +368,7 @@ impl fmt::Debug for File { } pub fn to_utf16(s: &Path) -> Vec<u16> { - s.as_os_str().encode_wide().chain(Some(0).into_iter()).collect() + s.as_os_str().encode_wide().chain(Some(0)).collect() } impl FileAttr { diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index b441d8beedb..b2a6607314a 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -38,6 +38,8 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> { impl AnonPipe { pub fn handle(&self) -> &Handle { &self.inner } + pub fn raw(&self) -> libc::HANDLE { self.inner.raw() } + pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { self.inner.read(buf) } diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 05073e60f5d..0b0268d4746 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -28,7 +28,6 @@ use sync::StaticMutex; use sys::c; use sys::fs::{OpenOptions, File}; use sys::handle::{Handle, RawHandle}; -use sys::pipe::AnonPipe; use sys::stdio; use sys::{self, cvt}; use sys_common::{AsInner, FromInner}; @@ -107,11 +106,12 @@ pub struct Process { pub enum Stdio { Inherit, - Piped(AnonPipe), None, - Handle(RawHandle), + Raw(libc::HANDLE), } +pub type RawStdio = Handle; + impl Process { pub fn spawn(cfg: &Command, in_handle: Stdio, @@ -356,15 +356,6 @@ fn make_dirp(d: Option<&OsString>) -> (*const u16, Vec<u16>) { } impl Stdio { - pub fn clone_if_copy(&self) -> Stdio { - match *self { - Stdio::Inherit => Stdio::Inherit, - Stdio::None => Stdio::None, - Stdio::Handle(handle) => Stdio::Handle(handle), - Stdio::Piped(_) => unreachable!(), - } - } - fn to_handle(&self, stdio_id: libc::DWORD) -> io::Result<Handle> { use libc::DUPLICATE_SAME_ACCESS; @@ -374,11 +365,8 @@ impl Stdio { io.handle().duplicate(0, true, DUPLICATE_SAME_ACCESS) }) } - Stdio::Handle(ref handle) => { - handle.duplicate(0, true, DUPLICATE_SAME_ACCESS) - } - Stdio::Piped(ref pipe) => { - pipe.handle().duplicate(0, true, DUPLICATE_SAME_ACCESS) + Stdio::Raw(handle) => { + RawHandle::new(handle).duplicate(0, true, DUPLICATE_SAME_ACCESS) } // Similarly to unix, we don't actually leave holes for the |
