diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-26 21:00:43 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-04 15:59:30 -0800 |
| commit | 95d904625b4d45af80b4e40d51a3a0fde1abaa8a (patch) | |
| tree | b0872e63b8d75543ce5141ceba44c12c459474f2 /src/librustc/util/common.rs | |
| parent | 3b3bb0e682c2d252e9f62dd9df5cff9552af91ad (diff) | |
| download | rust-95d904625b4d45af80b4e40d51a3a0fde1abaa8a.tar.gz rust-95d904625b4d45af80b4e40d51a3a0fde1abaa8a.zip | |
std: Deprecate std::old_io::fs
This commit deprecates the majority of std::old_io::fs in favor of std::fs and its new functionality. Some functions remain non-deprecated but are now behind a feature gate called `old_fs`. These functions will be deprecated once suitable replacements have been implemented. The compiler has been migrated to new `std::fs` and `std::path` APIs where appropriate as part of this change.
Diffstat (limited to 'src/librustc/util/common.rs')
| -rw-r--r-- | src/librustc/util/common.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index ca740f53782..0b32f7f69eb 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -12,11 +12,13 @@ use std::cell::{RefCell, Cell}; use std::collections::HashMap; +use std::collections::hash_state::HashState; +use std::ffi::CString; use std::fmt::Debug; use std::hash::Hash; use std::iter::repeat; +use std::path::Path; use std::time::Duration; -use std::collections::hash_state::HashState; use syntax::ast; use syntax::visit; @@ -222,3 +224,14 @@ pub fn memoized<T, U, S, F>(cache: &RefCell<HashMap<T, U, S>>, arg: T, f: F) -> } } } + +#[cfg(unix)] +pub fn path2cstr(p: &Path) -> CString { + use std::os::unix::prelude::*; + use std::ffi::AsOsStr; + CString::new(p.as_os_str().as_bytes()).unwrap() +} +#[cfg(windows)] +pub fn path2cstr(p: &Path) -> CString { + CString::new(p.to_str().unwrap()).unwrap() +} |
