Skip to content

Commit b4436f7

Browse files
committed
---
yaml --- r: 160185 b: refs/heads/snap-stage3 c: 5de56b3 h: refs/heads/master i: 160183: 30701d4 v: v3
1 parent 2d904a2 commit b4436f7

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: bfaa7bcab3459907014c31d3bf980f65ccd14b08
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6f422c4c05f4d108ba6429a174aa0c2ef3b183fa
4+
refs/heads/snap-stage3: 5de56b3ca1defd9206db8364ecef5f3fd8cc5b38
55
refs/heads/try: 225de0d60f8ca8dcc62ab2fd8818ebbda4b58cfe
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libstd/os.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -867,32 +867,33 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
867867
/// use std::path::Path;
868868
///
869869
/// let root = Path::new("/");
870-
/// assert!(os::change_dir(&root));
870+
/// assert!(os::change_dir(&root).is_ok());
871871
/// println!("Successfully changed working directory to {}!", root.display());
872872
/// ```
873-
pub fn change_dir(p: &Path) -> bool {
873+
pub fn change_dir(p: &Path) -> IoResult<()> {
874874
return chdir(p);
875875

876876
#[cfg(windows)]
877-
fn chdir(p: &Path) -> bool {
878-
let p = match p.as_str() {
879-
Some(s) => {
880-
let mut p = s.utf16_units().collect::<Vec<u16>>();
881-
p.push(0);
882-
p
883-
}
884-
None => return false,
885-
};
877+
fn chdir(p: &Path) -> IoResult<()> {
878+
let mut p = p.as_str().unwrap().utf16_units().collect::<Vec<u16>>();
879+
p.push(0);
880+
886881
unsafe {
887-
libc::SetCurrentDirectoryW(p.as_ptr()) != (0 as libc::BOOL)
882+
match libc::SetCurrentDirectoryW(p.as_ptr()) != (0 as libc::BOOL) {
883+
true => Ok(()),
884+
false => Err(IoError::last_error()),
885+
}
888886
}
889887
}
890888

891889
#[cfg(unix)]
892-
fn chdir(p: &Path) -> bool {
890+
fn chdir(p: &Path) -> IoResult<()> {
893891
p.with_c_str(|buf| {
894892
unsafe {
895-
libc::chdir(buf) == (0 as c_int)
893+
match libc::chdir(buf) == (0 as c_int) {
894+
true => Ok(()),
895+
false => Err(IoError::last_error()),
896+
}
896897
}
897898
})
898899
}

branches/snap-stage3/src/test/run-pass/tempfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub fn dont_double_panic() {
190190

191191
fn in_tmpdir(f: ||) {
192192
let tmpdir = TempDir::new("test").ok().expect("can't make tmpdir");
193-
assert!(os::change_dir(tmpdir.path()));
193+
assert!(os::change_dir(tmpdir.path()).is_ok());
194194

195195
f();
196196
}

0 commit comments

Comments
 (0)