File tree Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
10
10
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
11
11
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
12
12
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13
- refs/heads/auto: 6f422c4c05f4d108ba6429a174aa0c2ef3b183fa
13
+ refs/heads/auto: 5de56b3ca1defd9206db8364ecef5f3fd8cc5b38
14
14
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
15
15
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
16
16
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
Original file line number Diff line number Diff line change @@ -867,32 +867,33 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
867
867
/// use std::path::Path;
868
868
///
869
869
/// let root = Path::new("/");
870
- /// assert!(os::change_dir(&root));
870
+ /// assert!(os::change_dir(&root).is_ok() );
871
871
/// println!("Successfully changed working directory to {}!", root.display());
872
872
/// ```
873
- pub fn change_dir ( p : & Path ) -> bool {
873
+ pub fn change_dir ( p : & Path ) -> IoResult < ( ) > {
874
874
return chdir ( p) ;
875
875
876
876
#[ 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
+
886
881
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
+ }
888
886
}
889
887
}
890
888
891
889
#[ cfg( unix) ]
892
- fn chdir ( p : & Path ) -> bool {
890
+ fn chdir ( p : & Path ) -> IoResult < ( ) > {
893
891
p. with_c_str ( |buf| {
894
892
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
+ }
896
897
}
897
898
} )
898
899
}
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ pub fn dont_double_panic() {
190
190
191
191
fn in_tmpdir ( f: ||) {
192
192
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 ( ) ) ;
194
194
195
195
f ( ) ;
196
196
}
You can’t perform that action at this time.
0 commit comments