const TMPBUF_SZ: usize = 128;
fn bytes2path(b: &[u8]) -> PathBuf {
- PathBuf::new(<OsStr as OsStrExt>::from_bytes(b))
+ PathBuf::from(<OsStr as OsStrExt>::from_bytes(b))
}
fn os2path(os: OsString) -> PathBuf {
if err != 0 { return Err(io::Error::last_os_error()); }
if sz == 0 { return Err(io::Error::last_os_error()); }
v.set_len(sz as uint - 1); // chop off trailing NUL
- Ok(PathBuf::new::<OsString>(OsStringExt::from_vec(v)))
+ Ok(PathBuf::from(OsString::from_vec(v)))
}
}
Err(io::Error::last_os_error())
} else {
let vec = CStr::from_ptr(v).to_bytes().to_vec();
- Ok(PathBuf::new::<OsString>(OsStringExt::from_vec(vec)))
+ Ok(PathBuf::from(OsString::from_vec(vec)))
}
}
}
let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
if err != 0 { return Err(io::Error::last_os_error()); }
v.set_len(sz as uint - 1); // chop off trailing NUL
- Ok(PathBuf::new(OsString::from_vec(v)))
+ Ok(PathBuf::from(OsString::from_vec(v)))
}
}
pub fn temp_dir() -> PathBuf {
getenv("TMPDIR".as_os_str()).map(os2path).unwrap_or_else(|| {
if cfg!(target_os = "android") {
- PathBuf::new("/data/local/tmp")
+ PathBuf::from("/data/local/tmp")
} else {
- PathBuf::new("/tmp")
+ PathBuf::from("/tmp")
}
})
}