@@ -1311,9 +1311,39 @@ impl Write for &File {
1311
1311
}
1312
1312
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1313
1313
impl Seek for & File {
1314
+ /// Seek to an offset, in bytes in a file.
1315
+ ///
1316
+ /// See [`Seek::seek`] docs for more info.
1317
+ ///
1318
+ /// # Platform-specific behavior
1319
+ ///
1320
+ /// This function currently corresponds to the `lseek64` function on Unix
1321
+ /// and the `SetFilePointerEx` function on Windows. Note that this [may
1322
+ /// change in the future][changes].
1323
+ ///
1324
+ /// [changes]: io#platform-specific-behavior
1314
1325
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1315
1326
self . inner . seek ( pos)
1316
1327
}
1328
+
1329
+ /// Returns the length of this file (in bytes).
1330
+ ///
1331
+ /// See [`Seek::stream_len`] docs for more info.
1332
+ ///
1333
+ /// # Platform-specific behavior
1334
+ ///
1335
+ /// This function currently corresponds to the `statx` function on Linux
1336
+ /// (with fallbacks) and the `GetFileSizeEx` function on Windows. Note that
1337
+ /// this [may change in the future][changes].
1338
+ ///
1339
+ /// [changes]: io#platform-specific-behavior
1340
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1341
+ if let Some ( result) = self . inner . size ( ) {
1342
+ return result;
1343
+ }
1344
+ io:: stream_len_default ( self )
1345
+ }
1346
+
1317
1347
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1318
1348
self . inner . tell ( )
1319
1349
}
@@ -1363,6 +1393,9 @@ impl Seek for File {
1363
1393
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1364
1394
( & * self ) . seek ( pos)
1365
1395
}
1396
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1397
+ ( & * self ) . stream_len ( )
1398
+ }
1366
1399
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1367
1400
( & * self ) . stream_position ( )
1368
1401
}
@@ -1412,6 +1445,9 @@ impl Seek for Arc<File> {
1412
1445
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1413
1446
( & * * self ) . seek ( pos)
1414
1447
}
1448
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1449
+ ( & * * self ) . stream_len ( )
1450
+ }
1415
1451
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1416
1452
( & * * self ) . stream_position ( )
1417
1453
}
0 commit comments