File tree 8 files changed +42
-0
lines changed
8 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1229,6 +1229,9 @@ impl Seek for &File {
1229
1229
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1230
1230
self . inner . seek ( pos)
1231
1231
}
1232
+ fn stream_position ( & mut self ) -> io:: Result < u64 > {
1233
+ self . inner . tell ( )
1234
+ }
1232
1235
}
1233
1236
1234
1237
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1275,6 +1278,9 @@ impl Seek for File {
1275
1278
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1276
1279
( & * self ) . seek ( pos)
1277
1280
}
1281
+ fn stream_position ( & mut self ) -> io:: Result < u64 > {
1282
+ ( & * self ) . stream_position ( )
1283
+ }
1278
1284
}
1279
1285
1280
1286
#[ 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 {
425
425
Err ( Error :: from_raw_os_error ( 22 ) )
426
426
}
427
427
428
+ pub fn tell ( & self ) -> io:: Result < u64 > {
429
+ self . seek ( SeekFrom :: Current ( 0 ) )
430
+ }
431
+
428
432
pub fn duplicate ( & self ) -> io:: Result < File > {
429
433
Err ( Error :: from_raw_os_error ( 22 ) )
430
434
}
Original file line number Diff line number Diff line change @@ -465,6 +465,18 @@ impl File {
465
465
}
466
466
}
467
467
468
+ pub fn tell ( & self ) -> io:: Result < u64 > {
469
+ unsafe {
470
+ let mut out_offset = MaybeUninit :: uninit ( ) ;
471
+ error:: SolidError :: err_if_negative ( abi:: SOLID_FS_Ftell (
472
+ self . fd . raw ( ) ,
473
+ out_offset. as_mut_ptr ( ) ,
474
+ ) )
475
+ . map_err ( |e| e. as_io_error ( ) ) ?;
476
+ Ok ( out_offset. assume_init ( ) as u64 )
477
+ }
478
+ }
479
+
468
480
pub fn duplicate ( & self ) -> io:: Result < File > {
469
481
unsupported ( )
470
482
}
Original file line number Diff line number Diff line change @@ -258,6 +258,10 @@ impl File {
258
258
self . 0
259
259
}
260
260
261
+ pub fn tell ( & self ) -> io:: Result < u64 > {
262
+ self . 0
263
+ }
264
+
261
265
pub fn duplicate ( & self ) -> io:: Result < File > {
262
266
self . 0
263
267
}
Original file line number Diff line number Diff line change @@ -1438,6 +1438,10 @@ impl File {
1438
1438
Ok ( n as u64 )
1439
1439
}
1440
1440
1441
+ pub fn tell ( & self ) -> io:: Result < u64 > {
1442
+ self . seek ( SeekFrom :: Current ( 0 ) )
1443
+ }
1444
+
1441
1445
pub fn duplicate ( & self ) -> io:: Result < File > {
1442
1446
self . 0 . duplicate ( ) . map ( File )
1443
1447
}
Original file line number Diff line number Diff line change @@ -258,6 +258,10 @@ impl File {
258
258
self . 0
259
259
}
260
260
261
+ pub fn tell ( & self ) -> io:: Result < u64 > {
262
+ self . 0
263
+ }
264
+
261
265
pub fn duplicate ( & self ) -> io:: Result < File > {
262
266
self . 0
263
267
}
Original file line number Diff line number Diff line change @@ -517,6 +517,10 @@ impl File {
517
517
self . fd . seek ( pos)
518
518
}
519
519
520
+ pub fn tell ( & self ) -> io:: Result < u64 > {
521
+ self . fd . tell ( )
522
+ }
523
+
520
524
pub fn duplicate ( & self ) -> io:: Result < File > {
521
525
// https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-rationale.md#why-no-dup
522
526
unsupported ( )
Original file line number Diff line number Diff line change @@ -631,6 +631,10 @@ impl File {
631
631
Ok ( newpos as u64 )
632
632
}
633
633
634
+ pub fn tell ( & self ) -> io:: Result < u64 > {
635
+ self . seek ( SeekFrom :: Current ( 0 ) )
636
+ }
637
+
634
638
pub fn duplicate ( & self ) -> io:: Result < File > {
635
639
Ok ( Self { handle : self . handle . try_clone ( ) ? } )
636
640
}
You can’t perform that action at this time.
0 commit comments