@@ -1242,9 +1242,39 @@ impl Write for &File {
12421242}
12431243#[ stable( feature = "rust1" , since = "1.0.0" ) ]
12441244impl 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
12451256 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
12461257 self . inner . seek ( pos)
12471258 }
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+
12481278 fn stream_position ( & mut self ) -> io:: Result < u64 > {
12491279 self . inner . tell ( )
12501280 }
@@ -1294,6 +1324,9 @@ impl Seek for File {
12941324 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
12951325 ( & * self ) . seek ( pos)
12961326 }
1327+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1328+ ( & * self ) . stream_len ( )
1329+ }
12971330 fn stream_position ( & mut self ) -> io:: Result < u64 > {
12981331 ( & * self ) . stream_position ( )
12991332 }
@@ -1343,6 +1376,9 @@ impl Seek for Arc<File> {
13431376 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
13441377 ( & * * self ) . seek ( pos)
13451378 }
1379+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1380+ ( & * * self ) . stream_len ( )
1381+ }
13461382}
13471383
13481384impl OpenOptions {
0 commit comments