1.1.0[][src]Trait std::os::windows::fs::MetadataExt

pub trait MetadataExt {
    fn file_attributes(&self) -> u32;
fn creation_time(&self) -> u64;
fn last_access_time(&self) -> u64;
fn last_write_time(&self) -> u64;
fn file_size(&self) -> u64;
fn volume_serial_number(&self) -> Option<u32>;
fn number_of_links(&self) -> Option<u32>;
fn file_index(&self) -> Option<u64>; }
This is supported on Windows only.

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) -> u32

This is supported on Windows only.

Returns the value of the dwFileAttributes field 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(())
}
Run

fn creation_time(&self) -> u64

This is supported on Windows only.

Returns the value of the ftCreationTime field of this metadata.

The returned 64-bit value is equivalent to a FILETIME struct, which represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). The struct is automatically converted to a u64 value, 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(())
}
Run

fn last_access_time(&self) -> u64

This is supported on Windows only.

Returns the value of the ftLastAccessTime field of this metadata.

The returned 64-bit value is equivalent to a FILETIME struct, which represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). The struct is automatically converted to a u64 value, 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(())
}
Run

fn last_write_time(&self) -> u64

This is supported on Windows only.

Returns the value of the ftLastWriteTime field of this metadata.

The returned 64-bit value is equivalent to a FILETIME struct, which represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). The struct is automatically converted to a u64 value, 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(())
}
Run

fn file_size(&self) -> u64

This is supported on Windows only.

Returns the value of the nFileSize{High,Low} fields 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(())
}
Run

fn volume_serial_number(&self) -> Option<u32>

🔬 This is a nightly-only experimental API. (windows_by_handle #63010)
This is supported on Windows only.

Returns the value of the dwVolumeSerialNumber field of this metadata.

This will return None if the Metadata instance was created from a call to DirEntry::metadata. If this Metadata was created by using fs::metadata or File::metadata, then this will return Some.

🔬 This is a nightly-only experimental API. (windows_by_handle #63010)
This is supported on Windows only.

Returns the value of the nNumberOfLinks field of this metadata.

This will return None if the Metadata instance was created from a call to DirEntry::metadata. If this Metadata was created by using fs::metadata or File::metadata, then this will return Some.

fn file_index(&self) -> Option<u64>

🔬 This is a nightly-only experimental API. (windows_by_handle #63010)
This is supported on Windows only.

Returns the value of the nFileIndex{Low,High} fields of this metadata.

This will return None if the Metadata instance was created from a call to DirEntry::metadata. If this Metadata was created by using fs::metadata or File::metadata, then this will return Some.

Loading content...

Implementors

impl MetadataExt for Metadata[src]

Loading content...