silk.platform.windows.file_time.

Windows file metadata and timestamp helpers for cache maintenance and build fingerprinting.

When to use#

Use WindowsFileTime from cross-platform standard-library modules such as silk.system.file_time to query file sizes, modification and status-change timestamps, or to refresh modification times on Windows hosts without taking write-data access.

Details#

Single-call size and modification-time lookups use GetFileAttributesExW. Full modification and change-time lookups open the path with FILE_READ_ATTRIBUTES, full sharing, and FILE_FLAG_BACKUP_SEMANTICS and call GetFileInformationByHandleEx (FileBasicInfo). Updating timestamps opens the path with FILE_WRITE_ATTRIBUTES, full sharing, and FILE_FLAG_BACKUP_SEMANTICS (never GENERIC_WRITE) and calls SetFileTime.

Import as WindowsFileTime with import silk.platform.windows.file_time as WindowsFileTime.

Public declarations: 6.

WindowsFileMeta#

silk
pub struct WindowsFileMeta

Logical size, modification time, and directory flag read from one GetFileAttributesExW call.

Field bytes#

silk
pub bytes: u64

Logical byte length for regular files, or zero for directories.

Field modifiedSeconds#

silk
pub modifiedSeconds: i64

Last modification time in whole Unix seconds.

Field isDirectory#

silk
pub isDirectory: bool

True when the entry is a directory.

Implementation Copy for WindowsFileMeta#

silk
impl Copy for WindowsFileMeta

WindowsFileTimestamp#

silk
pub struct WindowsFileTimestamp

One file timestamp as whole Unix seconds and subsecond nanoseconds.

Field seconds#

silk
pub seconds: i64

Whole seconds since 1970-01-01T00:00:00Z.

Field nanoseconds#

silk
pub nanoseconds: u32

Nanoseconds after seconds, in the range 0 through 999999999.

Implementation Copy for WindowsFileTimestamp#

silk
impl Copy for WindowsFileTimestamp

WindowsFileTimestamps#

silk
pub struct WindowsFileTimestamps

Modification and status-change timestamps read from FILE_BASIC_INFO.

Field modified#

silk
pub modified: WindowsFileTimestamp

Last data modification time (LastWriteTime).

Field changed#

silk
pub changed: WindowsFileTimestamp

Last metadata or data change time (ChangeTime).

Implementation Copy for WindowsFileTimestamps#

silk
impl Copy for WindowsFileTimestamps

meta#

silk
pub effect fn meta(path: &Path) -> Option<WindowsFileMeta>

Returns the size, last modification time, and directory flag of path using one GetFileAttributesExW call, or None when the path cannot be queried.

timestamps#

silk
pub effect fn timestamps(path: &Path) -> Option<WindowsFileTimestamps>

Returns both the last-write and change timestamps of path using FileBasicInfo, or None when the path cannot be opened or queried.

setModifiedSeconds#

silk
pub effect fn setModifiedSeconds(path: &Path, seconds: i64) -> bool

Sets the last-access and last-write timestamps of path to whole Unix seconds. Opens the entry with FILE_WRITE_ATTRIBUTES and full sharing so concurrent readers are never blocked. Returns true when the timestamp update succeeds.

Category: Windows platform.

Profiles: x86_64-pc-windows-msvc.

View the source of this page