File tree 2 files changed +15
-2
lines changed
library/std/src/sys/pal/safaos 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,9 @@ pub fn getcwd() -> io::Result<PathBuf> {
31
31
Ok ( path)
32
32
}
33
33
34
- pub fn chdir ( _: & path:: Path ) -> io:: Result < ( ) > {
35
- unsupported ( )
34
+ pub fn chdir ( path : & path:: Path ) -> io:: Result < ( ) > {
35
+ syscalls:: chdir ( path) ?;
36
+ Ok ( ( ) )
36
37
}
37
38
38
39
pub struct SplitPaths < ' a > ( !, PhantomData < & ' a ( ) > ) ;
Original file line number Diff line number Diff line change 1
1
use crate :: arch:: asm;
2
2
use crate :: os:: safaos:: errors:: { ErrorStatus , SysSuccess } ;
3
+ use crate :: path:: Path ;
3
4
use core:: { ops, ptr} ;
4
5
5
6
/// Keep in sync with the kernel implementition
@@ -212,6 +213,17 @@ pub fn exit(code: usize) -> ! {
212
213
unreachable ! ( )
213
214
}
214
215
216
+ #[ inline( always) ]
217
+ fn syschdir ( buf : & [ u8 ] ) -> Result < SysSuccess , ErrorStatus > {
218
+ syscall2 ( SyscallNum :: SysCHDir , buf. as_ptr ( ) as usize , buf. len ( ) )
219
+ }
220
+
221
+ #[ inline]
222
+ pub fn chdir ( path : & Path ) -> Result < ( ) , ErrorStatus > {
223
+ let path = path. as_os_str ( ) . as_encoded_bytes ( ) ;
224
+ syschdir ( path) . map ( |SysSuccess | ( ) )
225
+ }
226
+
215
227
/// Gets the current working directory
216
228
/// returns Err(ErrorStatus::Generic) if the buffer is too small to hold the cwd
217
229
#[ inline( always) ]
You can’t perform that action at this time.
0 commit comments