@@ -1311,9 +1311,39 @@ impl Write for &File {
13111311}
13121312#[ stable( feature = "rust1" , since = "1.0.0" ) ]
13131313impl 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
13141325 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
13151326 self . inner . seek ( pos)
13161327 }
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+
13171347 fn stream_position ( & mut self ) -> io:: Result < u64 > {
13181348 self . inner . tell ( )
13191349 }
@@ -1363,6 +1393,9 @@ impl Seek for File {
13631393 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
13641394 ( & * self ) . seek ( pos)
13651395 }
1396+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1397+ ( & * self ) . stream_len ( )
1398+ }
13661399 fn stream_position ( & mut self ) -> io:: Result < u64 > {
13671400 ( & * self ) . stream_position ( )
13681401 }
@@ -1412,6 +1445,9 @@ impl Seek for Arc<File> {
14121445 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
14131446 ( & * * self ) . seek ( pos)
14141447 }
1448+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1449+ ( & * * self ) . stream_len ( )
1450+ }
14151451 fn stream_position ( & mut self ) -> io:: Result < u64 > {
14161452 ( & * * self ) . stream_position ( )
14171453 }
0 commit comments