From 95d904625b4d45af80b4e40d51a3a0fde1abaa8a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 26 Feb 2015 21:00:43 -0800 Subject: 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. --- src/librustc_llvm/archive_ro.rs | 16 ++++++++++++++-- src/librustc_llvm/lib.rs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/librustc_llvm') diff --git a/src/librustc_llvm/archive_ro.rs b/src/librustc_llvm/archive_ro.rs index 14a99026aac..f54480e3e52 100644 --- a/src/librustc_llvm/archive_ro.rs +++ b/src/librustc_llvm/archive_ro.rs @@ -16,6 +16,7 @@ use ArchiveRef; use std::ffi::CString; use std::mem; use std::raw; +use std::path::Path; pub struct ArchiveRO { ptr: ArchiveRef, @@ -29,14 +30,25 @@ impl ArchiveRO { /// If this archive is used with a mutable method, then an error will be /// raised. pub fn open(dst: &Path) -> Option { - unsafe { - let s = CString::new(dst.as_vec()).unwrap(); + return unsafe { + let s = path2cstr(dst); let ar = ::LLVMRustOpenArchive(s.as_ptr()); if ar.is_null() { None } else { Some(ArchiveRO { ptr: ar }) } + }; + + #[cfg(unix)] + 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)] + fn path2cstr(p: &Path) -> CString { + CString::new(p.to_str().unwrap()).unwrap() } } diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 09a187befb2..0a1416ff566 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -28,9 +28,9 @@ #![feature(int_uint)] #![feature(libc)] #![feature(link_args)] -#![feature(old_path)] #![feature(staged_api)] #![feature(std_misc)] +#![feature(path)] extern crate libc; #[macro_use] #[no_link] extern crate rustc_bitflags; -- cgit 1.4.1-3-g733a5