@@ -1226,9 +1226,38 @@ impl Write for &File {
12261226}
12271227#[ stable( feature = "rust1" , since = "1.0.0" ) ]
12281228impl Seek for & File {
1229+ /// Seek to an offset, in bytes in a file.
1230+ ///
1231+ /// See [`Seek::seek`] docs for more info.
1232+ ///
1233+ /// # Platform-specific behavior
1234+ ///
1235+ /// This function currently corresponds to the `lseek64` function on Unix
1236+ /// and the `SetFilePointerEx` function on Windows. Note that this [may
1237+ /// change in the future][changes].
1238+ ///
1239+ /// [changes]: io#platform-specific-behavior
12291240 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
12301241 self . inner . seek ( pos)
12311242 }
1243+
1244+ /// Returns the length of this file (in bytes).
1245+ ///
1246+ /// See [`Seek::stream_len`] docs for more info.
1247+ ///
1248+ /// # Platform-specific behavior
1249+ ///
1250+ /// This function currently corresponds to the `statx` function on Linux
1251+ /// (with fallbacks) and the `GetFileSizeEx` function on Windows. Note that
1252+ /// this [may change in the future][changes].
1253+ ///
1254+ /// [changes]: io#platform-specific-behavior
1255+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1256+ if let Some ( result) = self . inner . size ( ) {
1257+ return result;
1258+ }
1259+ io:: stream_len_default ( self )
1260+ }
12321261}
12331262
12341263#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1275,6 +1304,9 @@ impl Seek for File {
12751304 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
12761305 ( & * self ) . seek ( pos)
12771306 }
1307+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1308+ ( & * self ) . stream_len ( )
1309+ }
12781310}
12791311
12801312#[ stable( feature = "io_traits_arc" , since = "1.73.0" ) ]
@@ -1321,6 +1353,9 @@ impl Seek for Arc<File> {
13211353 fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
13221354 ( & * * self ) . seek ( pos)
13231355 }
1356+ fn stream_len ( & mut self ) -> io:: Result < u64 > {
1357+ ( & * * self ) . stream_len ( )
1358+ }
13241359}
13251360
13261361impl OpenOptions {
0 commit comments