Skip to content

Commit

Permalink
std: Stabilize portions of std::os::$platform
Browse files Browse the repository at this point in the history
This commit starts to organize the `std::os::$platform` modules and in the
process stabilizes some of the functionality contained within. The organization
of these modules will reflect the organization of the standard library itself
with extension traits for primitives in the same corresponding module.

The OS-specific modules will grow more functionality over time including
concrete types that are not extending functionality of other structures, and
these will either go into the closest module in `std::os::$platform` or they
will grow a new module in the hierarchy.

The following items are now stable:

* `os::{unix, windows}`
* `unix::ffi`
* `unix::ffi::OsStrExt`
* `unix::ffi::OsStrExt::{from_bytes, as_bytes, to_cstring}`
* `unix::ffi::OsString`
* `unix::ffi::OsStringExt::{from_vec, into_vec}`
* `unix::process`
* `unix::process::CommandExt`
* `unix::process::CommandExt::{uid, gid}`
* `unix::process::ExitStatusExt`
* `unix::process::ExitStatusExt::signal`
* `unix::prelude`
* `windows::ffi`
* `windows::ffi::OsStringExt`
* `windows::ffi::OsStringExt::from_wide`
* `windows::ffi::OsStrExt`
* `windows::ffi::OsStrExt::encode_wide`
* `windows::prelude`

The following items remain unstable:

* `unix::io`
* `unix::io::{Fd, AsRawFd}`
* `unix::fs::{PermissionsExt, OpenOptionsExt}`
* `windows::io`
* `windows::io::{Handle, AsRawHandle}`
* `windows::io::{Socket, AsRawSocket}`
* `windows::fs`
* `windows::fs::OpenOptionsExt`

Due to the reorgnization of the platform extension modules, this commit is a
breaking change. Most imports can be fixed by adding the relevant libstd module
in the `use` path (such as `ffi` or `fs`).

[breaking-change]
  • Loading branch information
alexcrichton committed Mar 15, 2015
1 parent 66853af commit 1f5f76a
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 323 deletions.
8 changes: 4 additions & 4 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {

#[cfg(unix)]
fn byteify(s: OsString) -> Vec<u8> {
use os::unix::*;
use os::unix::prelude::*;
s.into_vec()
}
#[cfg(windows)]
Expand Down Expand Up @@ -238,7 +238,7 @@ fn byteify(s: OsString) -> Vec<u8> {
pub fn setenv<T: BytesContainer>(n: &str, v: T) {
#[cfg(unix)]
fn _setenv(n: &str, v: &[u8]) {
use os::unix::*;
use os::unix::prelude::*;
let v: OsString = OsStringExt::from_vec(v.to_vec());
env::set_var(n, &v)
}
Expand Down Expand Up @@ -1705,13 +1705,13 @@ mod tests {

#[cfg(not(windows))]
fn get_fd(file: &File) -> libc::c_int {
use os::unix::AsRawFd;
use os::unix::prelude::*;
file.as_raw_fd()
}

#[cfg(windows)]
fn get_fd(file: &File) -> libc::HANDLE {
use os::windows::AsRawHandle;
use os::windows::prelude::*;
file.as_raw_handle()
}

Expand Down
6 changes: 3 additions & 3 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ mod tests {
#[cfg(all(unix, not(target_os="android")))]
#[test]
fn signal_reported_right() {
use os::unix::ExitStatusExt;
use os::unix::process::ExitStatusExt;

let p = Command::new("/bin/sh").arg("-c").arg("kill -9 $$").spawn();
assert!(p.is_ok());
Expand Down Expand Up @@ -633,7 +633,7 @@ mod tests {
#[cfg(all(unix, not(target_os="android")))]
#[test]
fn uid_works() {
use os::unix::*;
use os::unix::prelude::*;
use libc;
let mut p = Command::new("/bin/sh")
.arg("-c").arg("true")
Expand All @@ -646,7 +646,7 @@ mod tests {
#[cfg(all(unix, not(target_os="android")))]
#[test]
fn uid_to_root_fails() {
use os::unix::*;
use os::unix::prelude::*;
use libc;

// if we're already root, this isn't a valid test. Most of the bots run
Expand Down
Loading

0 comments on commit 1f5f76a

Please sign in to comment.