@@ -18,7 +18,9 @@ use path::Path;
18
18
use sys;
19
19
use sys_common:: { AsInnerMut , AsInner } ;
20
20
21
- /// Windows-specific extensions to `File`
21
+ /// Windows-specific extensions to [`File`].
22
+ ///
23
+ /// [`File`]: ../../../fs/struct.File.html
22
24
#[ stable( feature = "file_offset" , since = "1.15.0" ) ]
23
25
pub trait FileExt {
24
26
/// Seeks to a given position and reads a number of bytes.
@@ -103,7 +105,9 @@ impl FileExt for fs::File {
103
105
}
104
106
}
105
107
106
- /// Windows-specific extensions to `OpenOptions`
108
+ /// Windows-specific extensions to [`OpenOptions`].
109
+ ///
110
+ /// [`OpenOptions`]: ../../../fs/struct.OpenOptions.html
107
111
#[ stable( feature = "open_options_ext" , since = "1.10.0" ) ]
108
112
pub trait OpenOptionsExt {
109
113
/// Overrides the `dwDesiredAccess` argument to the call to [`CreateFile`]
@@ -267,42 +271,155 @@ impl OpenOptionsExt for OpenOptions {
267
271
}
268
272
}
269
273
270
- /// Extension methods for `fs::Metadata` to access the raw fields contained
274
+ /// Extension methods for [ `fs::Metadata`] to access the raw fields contained
271
275
/// within.
276
+ ///
277
+ /// The data members that this trait exposes correspond to the members
278
+ /// of the [`BY_HANDLE_FILE_INFORMATION`] structure.
279
+ ///
280
+ /// [`fs::Metadata`]: ../../../fs/struct.Metadata.html
281
+ /// [`BY_HANDLE_FILE_INFORMATION`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788.aspx
272
282
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
273
283
pub trait MetadataExt {
274
284
/// Returns the value of the `dwFileAttributes` field of this metadata.
275
285
///
276
286
/// This field contains the file system attribute information for a file
277
- /// or directory.
287
+ /// or directory. For possible values and their descriptions, see
288
+ /// [File Attribute Constants] in the Windows Dev Center.
289
+ ///
290
+ /// # Examples
291
+ ///
292
+ /// ```ignore
293
+ /// use std::io;
294
+ /// use std::io::prelude::*;
295
+ /// use std::fs::File;
296
+ /// use std::os::windows::prelude::*;
297
+ ///
298
+ /// # fn foo() -> io::Result<()> {
299
+ /// let mut file = File::open("foo.txt")?;
300
+ /// let attributes = file.file_attributes();
301
+ /// # }
302
+ /// ```
303
+ ///
304
+ /// [File Attribute Constants]: https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117.aspx
278
305
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
279
306
fn file_attributes ( & self ) -> u32 ;
280
307
281
308
/// Returns the value of the `ftCreationTime` field of this metadata.
282
309
///
283
- /// The returned 64-bit value represents the number of 100-nanosecond
284
- /// intervals since January 1, 1601 (UTC).
310
+ /// The returned 64-bit value is equivalent to a [`FILETIME`] struct,
311
+ /// which represents the number of 100-nanosecond intervals since
312
+ /// January 1, 1601 (UTC). The struct is automatically
313
+ /// converted to a `u64` value, as that is the recommended way
314
+ /// to use it.
315
+ ///
316
+ /// If the underlying filesystem does not support creation time, the
317
+ /// returned value is 0.
318
+ ///
319
+ /// # Examples
320
+ ///
321
+ /// ```ignore
322
+ /// use std::io;
323
+ /// use std::io::prelude::*;
324
+ /// use std::fs::File;
325
+ /// use std::os::windows::prelude::*;
326
+ ///
327
+ /// # fn foo() -> io::Result<()> {
328
+ /// let mut file = File::open("foo.txt")?;
329
+ /// let creation_time = file.creation_time();
330
+ /// # }
331
+ /// ```
332
+ ///
333
+ /// [`FILETIME`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx
285
334
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
286
335
fn creation_time ( & self ) -> u64 ;
287
336
288
337
/// Returns the value of the `ftLastAccessTime` field of this metadata.
289
338
///
290
- /// The returned 64-bit value represents the number of 100-nanosecond
291
- /// intervals since January 1, 1601 (UTC).
339
+ /// The returned 64-bit value is equivalent to a [`FILETIME`] struct,
340
+ /// which represents the number of 100-nanosecond intervals since
341
+ /// January 1, 1601 (UTC). The struct is automatically
342
+ /// converted to a `u64` value, as that is the recommended way
343
+ /// to use it.
344
+ ///
345
+ /// For a file, the value specifies the last time that a file was read
346
+ /// from or written to. For a directory, the value specifies when
347
+ /// the directory was created. For both files and directories, the
348
+ /// specified date is correct, but the time of day is always set to
349
+ /// midnight.
350
+ ///
351
+ /// If the underlying filesystem does not support last access time, the
352
+ /// returned value is 0.
353
+ ///
354
+ /// # Examples
355
+ ///
356
+ /// ```ignore
357
+ /// use std::io;
358
+ /// use std::io::prelude::*;
359
+ /// use std::fs::File;
360
+ /// use std::os::windows::prelude::*;
361
+ ///
362
+ /// # fn foo() -> io::Result<()> {
363
+ /// let mut file = File::open("foo.txt")?;
364
+ /// let last_access_time = file.last_access_time();
365
+ /// # }
366
+ /// ```
367
+ ///
368
+ /// [`FILETIME`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx
292
369
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
293
370
fn last_access_time ( & self ) -> u64 ;
294
371
295
372
/// Returns the value of the `ftLastWriteTime` field of this metadata.
296
373
///
297
- /// The returned 64-bit value represents the number of 100-nanosecond
298
- /// intervals since January 1, 1601 (UTC).
374
+ /// The returned 64-bit value is equivalent to a [`FILETIME`] struct,
375
+ /// which represents the number of 100-nanosecond intervals since
376
+ /// January 1, 1601 (UTC). The struct is automatically
377
+ /// converted to a `u64` value, as that is the recommended way
378
+ /// to use it.
379
+ ///
380
+ /// For a file, the value specifies the last time that a file was written
381
+ /// to. For a directory, the structure specifies when the directory was
382
+ /// created.
383
+ ///
384
+ /// If the underlying filesystem does not support the last write time
385
+ /// time, the returned value is 0.
386
+ ///
387
+ /// # Examples
388
+ ///
389
+ /// ```ignore
390
+ /// use std::io;
391
+ /// use std::io::prelude::*;
392
+ /// use std::fs::File;
393
+ /// use std::os::windows::prelude::*;
394
+ ///
395
+ /// # fn foo() -> io::Result<()> {
396
+ /// let mut file = File::open("foo.txt")?;
397
+ /// let last_write_time = file.last_write_time();
398
+ /// # }
399
+ /// ```
400
+ ///
401
+ /// [`FILETIME`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx
299
402
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
300
403
fn last_write_time ( & self ) -> u64 ;
301
404
302
405
/// Returns the value of the `nFileSize{High,Low}` fields of this
303
406
/// metadata.
304
407
///
305
408
/// The returned value does not have meaning for directories.
409
+ ///
410
+ /// # Examples
411
+ ///
412
+ /// ```ignore
413
+ /// use std::io;
414
+ /// use std::io::prelude::*;
415
+ /// use std::fs::File;
416
+ /// use std::os::windows::prelude::*;
417
+ ///
418
+ /// # fn foo() -> io::Result<()> {
419
+ /// let mut file = File::open("foo.txt")?;
420
+ /// let file_size = file.file_size();
421
+ /// # }
422
+ /// ```
306
423
#[ stable( feature = "metadata_ext" , since = "1.1.0" ) ]
307
424
fn file_size ( & self ) -> u64 ;
308
425
}
0 commit comments