@@ -1247,9 +1247,39 @@ impl Write for &File {
1247
1247
}
1248
1248
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1249
1249
impl Seek for & File {
1250
+ /// Seek to an offset, in bytes in a file.
1251
+ ///
1252
+ /// See [`Seek::seek`] docs for more info.
1253
+ ///
1254
+ /// # Platform-specific behavior
1255
+ ///
1256
+ /// This function currently corresponds to the `lseek64` function on Unix
1257
+ /// and the `SetFilePointerEx` function on Windows. Note that this [may
1258
+ /// change in the future][changes].
1259
+ ///
1260
+ /// [changes]: io#platform-specific-behavior
1250
1261
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1251
1262
self . inner . seek ( pos)
1252
1263
}
1264
+
1265
+ /// Returns the length of this file (in bytes).
1266
+ ///
1267
+ /// See [`Seek::stream_len`] docs for more info.
1268
+ ///
1269
+ /// # Platform-specific behavior
1270
+ ///
1271
+ /// This function currently corresponds to the `statx` function on Linux
1272
+ /// (with fallbacks) and the `GetFileSizeEx` function on Windows. Note that
1273
+ /// this [may change in the future][changes].
1274
+ ///
1275
+ /// [changes]: io#platform-specific-behavior
1276
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1277
+ if let Some ( result) = self . inner . size ( ) {
1278
+ return result;
1279
+ }
1280
+ io:: stream_len_default ( self )
1281
+ }
1282
+
1253
1283
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1254
1284
self . inner . tell ( )
1255
1285
}
@@ -1299,6 +1329,9 @@ impl Seek for File {
1299
1329
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1300
1330
( & * self ) . seek ( pos)
1301
1331
}
1332
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1333
+ ( & * self ) . stream_len ( )
1334
+ }
1302
1335
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1303
1336
( & * self ) . stream_position ( )
1304
1337
}
@@ -1348,6 +1381,9 @@ impl Seek for Arc<File> {
1348
1381
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1349
1382
( & * * self ) . seek ( pos)
1350
1383
}
1384
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1385
+ ( & * * self ) . stream_len ( )
1386
+ }
1351
1387
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1352
1388
( & * * self ) . stream_position ( )
1353
1389
}
0 commit comments