File tree Expand file tree Collapse file tree 8 files changed +34
-1
lines changed Expand file tree Collapse file tree 8 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1229,6 +1229,9 @@ impl Seek for &File {
12291229 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
12301230 self . inner . seek ( pos)
12311231 }
1232+ fn stream_position ( & mut self ) -> io:: Result < u64 > {
1233+ self . inner . tell ( )
1234+ }
12321235}
12331236
12341237#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1275,6 +1278,9 @@ impl Seek for File {
12751278 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
12761279 ( & * self ) . seek ( pos)
12771280 }
1281+ fn stream_position ( & mut self ) -> io:: Result < u64 > {
1282+ ( & * self ) . stream_position ( )
1283+ }
12781284}
12791285
12801286#[ stable( feature = "io_traits_arc" , since = "1.73.0" ) ]
Original file line number Diff line number Diff line change @@ -421,6 +421,10 @@ impl File {
421421 Err ( Error :: from_raw_os_error ( 22 ) )
422422 }
423423
424+ pub fn tell ( & self ) -> io:: Result < u64 > {
425+ self . seek ( SeekFrom :: Current ( 0 ) )
426+ }
427+
424428 pub fn duplicate ( & self ) -> io:: Result < File > {
425429 Err ( Error :: from_raw_os_error ( 22 ) )
426430 }
Original file line number Diff line number Diff line change @@ -452,8 +452,11 @@ impl File {
452452 abi:: SOLID_FS_Lseek ( self . fd . raw ( ) , pos, whence)
453453 } )
454454 . map_err ( |e| e. as_io_error ( ) ) ?;
455-
456455 // Get the new offset
456+ self . tell ( )
457+ }
458+
459+ pub fn tell ( & self ) -> io:: Result < u64 > {
457460 unsafe {
458461 let mut out_offset = MaybeUninit :: uninit ( ) ;
459462 error:: SolidError :: err_if_negative ( abi:: SOLID_FS_Ftell (
Original file line number Diff line number Diff line change @@ -258,6 +258,10 @@ impl File {
258258 self . 0
259259 }
260260
261+ pub fn tell ( & self ) -> io:: Result < u64 > {
262+ self . 0
263+ }
264+
261265 pub fn duplicate ( & self ) -> io:: Result < File > {
262266 self . 0
263267 }
Original file line number Diff line number Diff line change @@ -1437,6 +1437,10 @@ impl File {
14371437 Ok ( n as u64 )
14381438 }
14391439
1440+ pub fn tell ( & self ) -> io:: Result < u64 > {
1441+ self . seek ( SeekFrom :: Current ( 0 ) )
1442+ }
1443+
14401444 pub fn duplicate ( & self ) -> io:: Result < File > {
14411445 self . 0 . duplicate ( ) . map ( File )
14421446 }
Original file line number Diff line number Diff line change @@ -258,6 +258,10 @@ impl File {
258258 self . 0
259259 }
260260
261+ pub fn tell ( & self ) -> io:: Result < u64 > {
262+ self . 0
263+ }
264+
261265 pub fn duplicate ( & self ) -> io:: Result < File > {
262266 self . 0
263267 }
Original file line number Diff line number Diff line change @@ -517,6 +517,10 @@ impl File {
517517 self . fd . seek ( pos)
518518 }
519519
520+ pub fn tell ( & self ) -> io:: Result < u64 > {
521+ self . fd . tell ( )
522+ }
523+
520524 pub fn duplicate ( & self ) -> io:: Result < File > {
521525 // https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-rationale.md#why-no-dup
522526 unsupported ( )
Original file line number Diff line number Diff line change @@ -631,6 +631,10 @@ impl File {
631631 Ok ( newpos as u64 )
632632 }
633633
634+ pub fn tell ( & self ) -> io:: Result < u64 > {
635+ self . seek ( SeekFrom :: Current ( 0 ) )
636+ }
637+
634638 pub fn duplicate ( & self ) -> io:: Result < File > {
635639 Ok ( Self { handle : self . handle . try_clone ( ) ? } )
636640 }
You can’t perform that action at this time.
0 commit comments