about summary refs log tree commit diff
path: root/src/libstd/sys/windows/mod.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-02-25 10:29:39 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-02-25 10:29:39 +0530
commitb18584cbd942e2559e718d6318fdbc494e9047bd (patch)
tree3be7b8533626450b30f233f725a716546159090d /src/libstd/sys/windows/mod.rs
parent7b7cf84975fa9da0a301028b28be8b255f2fcd6f (diff)
parent2d200c9c8bd6659720a68ab8dd74218b1e58c1e9 (diff)
Rollup merge of #22727 - alexcrichton:prep-env, r=aturon
 This commit moves `std::env` away from the `std::old_io` error type as well as
the `std::old_path` module. Methods returning an error now return `io::Error`
and methods consuming or returning paths use `std::path` instead of
`std::old_path`. This commit does not yet mark these APIs as `#[stable]`.

This commit also migrates `std::old_io::TempDir` to `std::fs::TempDir` with
essentially the exact same API. This type was added to interoperate with the new
path API and has its own `tempdir` feature.

Finally, this commit reverts the deprecation of `std::os` APIs returning the old
path API types. This deprecation can come back once the entire `std::old_path`
module is deprecated.

[breaking-change]
Diffstat (limited to 'src/libstd/sys/windows/mod.rs')
-rw-r--r--src/libstd/sys/windows/mod.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 3acb372f658..6e3b48a8f64 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -14,13 +14,14 @@
 
 use prelude::v1::*;
 
-use ffi::OsStr;
+use ffi::{OsStr, OsString};
 use io::{self, ErrorKind};
 use libc;
 use mem;
-use old_io::{self, IoResult, IoError};
 use num::Int;
-use os::windows::OsStrExt;
+use old_io::{self, IoResult, IoError};
+use os::windows::{OsStrExt, OsStringExt};
+use path::PathBuf;
 use sync::{Once, ONCE_INIT};
 
 macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => (
@@ -314,9 +315,10 @@ fn fill_utf16_buf_new<F1, F2, T>(f1: F1, f2: F2) -> io::Result<T>
     fill_utf16_buf_base(f1, f2).map_err(|()| io::Error::last_os_error())
 }
 
-fn os2path(s: &[u16]) -> Path {
-    // FIXME: this should not be a panicking conversion (aka path reform)
-    Path::new(String::from_utf16(s).unwrap())
+fn os2path(s: &[u16]) -> PathBuf {
+    let os = <OsString as OsStringExt>::from_wide(s);
+    // FIXME(#22751) should consume `os`
+    PathBuf::new(&os)
 }
 
 pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {