mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-30 08:34:07 +00:00
Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahc
Simplify chdir implementation and minimize unsafe block
This commit is contained in:
commit
2ed0134cfa
@ -155,12 +155,10 @@ pub fn getcwd() -> io::Result<PathBuf> {
|
||||
pub fn chdir(p: &path::Path) -> io::Result<()> {
|
||||
let p: &OsStr = p.as_ref();
|
||||
let p = CString::new(p.as_bytes())?;
|
||||
unsafe {
|
||||
match libc::chdir(p.as_ptr()) == (0 as c_int) {
|
||||
true => Ok(()),
|
||||
false => Err(io::Error::last_os_error()),
|
||||
}
|
||||
if unsafe { libc::chdir(p.as_ptr()) } != 0 {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct SplitPaths<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user