Trait MetadataExt
trait MetadataExt
Windows-specific extensions to fs::Metadata.
The data members that this trait exposes correspond to the members
of the BY_HANDLE_FILE_INFORMATION structure.
Required Methods
fn file_attributes(self: &Self) -> u32Returns the value of the
dwFileAttributesfield of this metadata.This field contains the file system attribute information for a file or directory. For possible values and their descriptions, see File Attribute Constants in the Windows Dev Center.
Examples
use std::io; use std::fs; use std::os::windows::prelude::*; fn main() -> io::Result<()> { let metadata = fs::metadata("foo.txt")?; let attributes = metadata.file_attributes(); Ok(()) }fn creation_time(self: &Self) -> u64Returns the value of the
ftCreationTimefield of this metadata.The returned 64-bit value is equivalent to a
FILETIMEstruct, which represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). The struct is automatically converted to au64value, as that is the recommended way to use it.If the underlying filesystem does not support creation time, the returned value is 0.
Examples
use std::io; use std::fs; use std::os::windows::prelude::*; fn main() -> io::Result<()> { let metadata = fs::metadata("foo.txt")?; let creation_time = metadata.creation_time(); Ok(()) }fn last_access_time(self: &Self) -> u64Returns the value of the
ftLastAccessTimefield of this metadata.The returned 64-bit value is equivalent to a
FILETIMEstruct, which represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). The struct is automatically converted to au64value, as that is the recommended way to use it.For a file, the value specifies the last time that a file was read from or written to. For a directory, the value specifies when the directory was created. For both files and directories, the specified date is correct, but the time of day is always set to midnight.
If the underlying filesystem does not support last access time, the returned value is 0.
Examples
use std::io; use std::fs; use std::os::windows::prelude::*; fn main() -> io::Result<()> { let metadata = fs::metadata("foo.txt")?; let last_access_time = metadata.last_access_time(); Ok(()) }fn last_write_time(self: &Self) -> u64Returns the value of the
ftLastWriteTimefield of this metadata.The returned 64-bit value is equivalent to a
FILETIMEstruct, which represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). The struct is automatically converted to au64value, as that is the recommended way to use it.For a file, the value specifies the last time that a file was written to. For a directory, the structure specifies when the directory was created.
If the underlying filesystem does not support the last write time, the returned value is 0.
Examples
use std::io; use std::fs; use std::os::windows::prelude::*; fn main() -> io::Result<()> { let metadata = fs::metadata("foo.txt")?; let last_write_time = metadata.last_write_time(); Ok(()) }fn file_size(self: &Self) -> u64Returns the value of the
nFileSizefields of this metadata.The returned value does not have meaning for directories.
Examples
use std::io; use std::fs; use std::os::windows::prelude::*; fn main() -> io::Result<()> { let metadata = fs::metadata("foo.txt")?; let file_size = metadata.file_size(); Ok(()) }fn volume_serial_number(self: &Self) -> Option<u32>Returns the value of the
dwVolumeSerialNumberfield of this metadata.This will return
Noneif theMetadatainstance was created from a call toDirEntry::metadata. If thisMetadatawas created by usingfs::metadataorFile::metadata, then this will returnSome.fn number_of_links(self: &Self) -> Option<u32>Returns the value of the
nNumberOfLinksfield of this metadata.This will return
Noneif theMetadatainstance was created from a call toDirEntry::metadata. If thisMetadatawas created by usingfs::metadataorFile::metadata, then this will returnSome.fn file_index(self: &Self) -> Option<u64>Returns the value of the
nFileIndexfields of this metadata.This will return
Noneif theMetadatainstance was created from a call toDirEntry::metadata. If thisMetadatawas created by usingfs::metadataorFile::metadata, then this will returnSome.fn change_time(self: &Self) -> Option<u64>Returns the value of the
ChangeTimefields of this metadata.ChangeTimeis the last time file metadata was changed, such as renames, attributes, etc.This will return
NoneifMetadatainstance was created from a call toDirEntry::metadataor if thetarget_vendoris outside the current platform support for this api.
Implementors
impl MetadataExt for crate::fs::Metadata