File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,21 @@ fn remove_dir(p: path) -> bool {
178
178
}
179
179
}
180
180
181
+ fn change_dir ( p : path ) -> bool {
182
+ ret chdir ( p) ;
183
+
184
+ #[ cfg( target_os = "win32" ) ]
185
+ fn chdir ( _p : path ) -> bool {
186
+ ret str:: as_buf ( _p, { |buf| os:: kernel32:: SetCurrentDirectory ( buf) } ) ;
187
+ }
188
+
189
+ #[ cfg( target_os = "linux" ) ]
190
+ #[ cfg( target_os = "macos" ) ]
191
+ fn chdir ( _p : path ) -> bool {
192
+ ret str:: as_buf ( _p, { |buf| os:: libc:: chdir ( buf) == 0i32 } ) ;
193
+ }
194
+ }
195
+
181
196
/*
182
197
Function: path_is_absolute
183
198
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ native mod libc {
53
53
fn readlink ( path : str:: sbuf , buf : str:: sbuf , bufsize : size_t ) -> ssize_t ;
54
54
fn mkdir ( path : str:: sbuf , mode : c_int ) -> c_int ;
55
55
fn rmdir ( path : str:: sbuf ) -> c_int ;
56
+ fn chdir ( path : str:: sbuf ) -> c_int ;
56
57
}
57
58
58
59
mod libc_constants {
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ native mod libc {
46
46
fn waitpid ( pid : pid_t , & status: c_int , options : c_int ) -> c_int ;
47
47
fn mkdir ( s : str:: sbuf , mode : c_int ) -> c_int ;
48
48
fn rmdir ( s : str:: sbuf ) -> c_int ;
49
+ fn chdir ( s : str:: sbuf ) -> c_int ;
49
50
}
50
51
51
52
mod libc_constants {
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ native mod kernel32 {
55
55
fn CreateDirectoryA ( lpPathName : LPCTSTR ,
56
56
lpSecurityAttributes : LPSECURITY_ATTRIBUTES ) -> bool ;
57
57
fn RemoveDirectoryA ( lpPathName : LPCTSTR ) -> bool ;
58
+ fn SetCurrentDirectory ( lpPathName : LPCTSTR ) -> bool ;
58
59
}
59
60
60
61
// FIXME turn into constants
You can’t perform that action at this time.
0 commit comments