##// END OF EJS Templates
rust: convert Unix path to CString transparently...
Yuya Nishihara -
r35650:fa9747e7 default
parent child Browse files
Show More
@@ -16,7 +16,7 b' use std::env;'
16 use std::path::PathBuf;
16 use std::path::PathBuf;
17 use std::ffi::{CString, OsStr};
17 use std::ffi::{CString, OsStr};
18 #[cfg(target_family = "unix")]
18 #[cfg(target_family = "unix")]
19 use std::os::unix::ffi::OsStringExt;
19 use std::os::unix::ffi::{OsStrExt, OsStringExt};
20
20
21 #[derive(Debug)]
21 #[derive(Debug)]
22 struct Environment {
22 struct Environment {
@@ -62,6 +62,14 b' fn get_environment() -> Environment {'
62 }
62 }
63 }
63 }
64
64
65 // On UNIX, platform string is just bytes and should not contain NUL.
66 #[cfg(target_family = "unix")]
67 fn cstring_from_os<T: AsRef<OsStr>>(s: T) -> CString {
68 CString::new(s.as_ref().as_bytes()).unwrap()
69 }
70
71 // TODO convert to ANSI characters?
72 #[cfg(target_family = "windows")]
65 fn cstring_from_os<T: AsRef<OsStr>>(s: T) -> CString {
73 fn cstring_from_os<T: AsRef<OsStr>>(s: T) -> CString {
66 CString::new(s.as_ref().to_str().unwrap()).unwrap()
74 CString::new(s.as_ref().to_str().unwrap()).unwrap()
67 }
75 }
General Comments 0
You need to be logged in to leave comments. Login now