@@ -68,7 +68,8 @@ impl DirIterResource {
68
68
}
69
69
70
70
fn next ( & mut self ) -> Option < raw:: DirEntry > {
71
- let raw = syscalls:: diriter_next ( self . 0 ) . unwrap ( ) ;
71
+ // should never error expect if there is no more entries it returns ErrorStatus::Generic
72
+ let raw = syscalls:: diriter_next ( self . 0 ) . ok ( ) ?;
72
73
if raw == unsafe { core:: mem:: zeroed ( ) } { None } else { Some ( raw) }
73
74
}
74
75
}
@@ -364,8 +365,16 @@ impl File {
364
365
}
365
366
366
367
pub fn read ( & self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
367
- let at = unsafe { * self . seek_at . get ( ) } ;
368
- Ok ( self . fd . read ( at, buf) ?)
368
+ let at = unsafe { & mut * self . seek_at . get ( ) } ;
369
+
370
+ let read = match self . fd . read ( * at, buf) {
371
+ Ok ( amount) => amount,
372
+ Err ( ErrorStatus :: InvaildOffset ) => return Ok ( 0 ) ,
373
+ Err ( other) => return Err ( other. into ( ) ) ,
374
+ } ;
375
+ * at += read as isize ;
376
+
377
+ Ok ( read)
369
378
}
370
379
371
380
pub fn read_vectored ( & self , _bufs : & mut [ IoSliceMut < ' _ > ] ) -> io:: Result < usize > {
@@ -376,13 +385,21 @@ impl File {
376
385
false
377
386
}
378
387
379
- pub fn read_buf ( & self , _cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
380
- todo ! ( )
388
+ pub fn read_buf ( & self , cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
389
+ crate :: io :: default_read_buf ( |buf| self . read ( buf ) , cursor )
381
390
}
382
391
383
392
pub fn write ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
384
- let at = unsafe { * self . seek_at . get ( ) } ;
385
- Ok ( self . fd . write ( at, buf) ?)
393
+ let at = unsafe { & mut * self . seek_at . get ( ) } ;
394
+
395
+ let wrote = match self . fd . write ( * at, buf) {
396
+ Ok ( amount) => amount,
397
+ Err ( ErrorStatus :: InvaildOffset ) => return Ok ( 0 ) ,
398
+ Err ( other) => return Err ( other. into ( ) ) ,
399
+ } ;
400
+ * at += wrote as isize ;
401
+
402
+ Ok ( wrote)
386
403
}
387
404
388
405
pub fn write_vectored ( & self , _bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
0 commit comments