@@ -1242,9 +1242,39 @@ impl Write for &File {
1242
1242
}
1243
1243
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1244
1244
impl Seek for & File {
1245
+ /// Seek to an offset, in bytes in a file.
1246
+ ///
1247
+ /// See [`Seek::seek`] docs for more info.
1248
+ ///
1249
+ /// # Platform-specific behavior
1250
+ ///
1251
+ /// This function currently corresponds to the `lseek64` function on Unix
1252
+ /// and the `SetFilePointerEx` function on Windows. Note that this [may
1253
+ /// change in the future][changes].
1254
+ ///
1255
+ /// [changes]: io#platform-specific-behavior
1245
1256
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1246
1257
self . inner . seek ( pos)
1247
1258
}
1259
+
1260
+ /// Returns the length of this file (in bytes).
1261
+ ///
1262
+ /// See [`Seek::stream_len`] docs for more info.
1263
+ ///
1264
+ /// # Platform-specific behavior
1265
+ ///
1266
+ /// This function currently corresponds to the `statx` function on Linux
1267
+ /// (with fallbacks) and the `GetFileSizeEx` function on Windows. Note that
1268
+ /// this [may change in the future][changes].
1269
+ ///
1270
+ /// [changes]: io#platform-specific-behavior
1271
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1272
+ if let Some ( result) = self . inner . size ( ) {
1273
+ return result;
1274
+ }
1275
+ io:: stream_len_default ( self )
1276
+ }
1277
+
1248
1278
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1249
1279
self . inner . tell ( )
1250
1280
}
@@ -1294,6 +1324,9 @@ impl Seek for File {
1294
1324
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1295
1325
( & * self ) . seek ( pos)
1296
1326
}
1327
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1328
+ ( & * self ) . stream_len ( )
1329
+ }
1297
1330
fn stream_position ( & mut self ) -> io:: Result < u64 > {
1298
1331
( & * self ) . stream_position ( )
1299
1332
}
@@ -1343,6 +1376,9 @@ impl Seek for Arc<File> {
1343
1376
fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
1344
1377
( & * * self ) . seek ( pos)
1345
1378
}
1379
+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1380
+ ( & * * self ) . stream_len ( )
1381
+ }
1346
1382
}
1347
1383
1348
1384
impl OpenOptions {
0 commit comments