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 @@ -425,6 +425,10 @@ impl File {
425425 Err ( Error :: from_raw_os_error ( 22 ) )
426426 }
427427
428+ pub fn tell ( & self ) -> io:: Result < u64 > {
429+ self . seek ( SeekFrom :: Current ( 0 ) )
430+ }
431+
428432 pub fn duplicate ( & self ) -> io:: Result < File > {
429433 Err ( Error :: from_raw_os_error ( 22 ) )
430434 }
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 @@ -1438,6 +1438,10 @@ impl File {
14381438 Ok ( n as u64 )
14391439 }
14401440
1441+ pub fn tell ( & self ) -> io:: Result < u64 > {
1442+ self . seek ( SeekFrom :: Current ( 0 ) )
1443+ }
1444+
14411445 pub fn duplicate ( & self ) -> io:: Result < File > {
14421446 self . 0 . duplicate ( ) . map ( File )
14431447 }
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