File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1212,15 +1212,15 @@ dependencies = [
1212
1212
1213
1213
[[package ]]
1214
1214
name = " emerald_kernel_user_link"
1215
- version = " 0.2.4 "
1215
+ version = " 0.2.7 "
1216
1216
dependencies = [
1217
1217
" compiler_builtins" ,
1218
1218
" rustc-std-workspace-core" ,
1219
1219
]
1220
1220
1221
1221
[[package ]]
1222
1222
name = " emerald_std"
1223
- version = " 0.2.7 "
1223
+ version = " 0.2.8 "
1224
1224
dependencies = [
1225
1225
" compiler_builtins" ,
1226
1226
" emerald_kernel_user_link" ,
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }
61
61
# This is from `https://github.com/Amjad50/Emerald`, i.e. it must be run from that context
62
62
# TODO: for now we are using relative path, as we are using `libm` from `git` and we can't publish
63
63
# that. Fix it later
64
- emerald_std = { version = " 0.2.5 " , features = [' rustc-dep-of-std' ], path = " ../../../../libraries/emerald_std" }
64
+ emerald_std = { version = " 0.2.8 " , features = [' rustc-dep-of-std' ], path = " ../../../../libraries/emerald_std" }
65
65
66
66
[features ]
67
67
backtrace = [
Original file line number Diff line number Diff line change 1
1
use core:: ffi:: CStr ;
2
2
3
- use emerald_std:: io:: FileStat ;
3
+ use emerald_std:: io:: { FileStat , SeekWhence } ;
4
4
5
5
use crate :: ffi:: OsString ;
6
6
use crate :: fmt;
@@ -300,8 +300,20 @@ impl File {
300
300
Ok ( ( ) )
301
301
}
302
302
303
- pub fn seek ( & self , _pos : SeekFrom ) -> io:: Result < u64 > {
304
- todo ! ( )
303
+ pub fn seek ( & self , pos : SeekFrom ) -> io:: Result < u64 > {
304
+ let ( whence, offset) = match pos {
305
+ // Casting to `i64` is fine, too large values will end up as
306
+ // negative which will cause an error in `sys_seek`.
307
+ SeekFrom :: Start ( off) => ( SeekWhence :: Start , off as i64 ) ,
308
+ SeekFrom :: Current ( off) => ( SeekWhence :: Current , off) ,
309
+ SeekFrom :: End ( off) => ( SeekWhence :: End , off) ,
310
+ } ;
311
+
312
+ let seek = emerald_std:: io:: SeekFrom { whence, offset } ;
313
+
314
+ unsafe {
315
+ emerald_std:: io:: syscall_seek ( self . fd . as_raw_fd ( ) , seek) . map_err ( syscall_to_io_error)
316
+ }
305
317
}
306
318
307
319
pub fn duplicate ( & self ) -> io:: Result < File > {
You can’t perform that action at this time.
0 commit comments