silk.system.file_time.
Cross-platform host file metadata and timestamp operations for caches and build tools.
When to use#
Use FileTime when a build system or cache manager needs a single-syscall size and
modification-time lookup (meta), full modification and change timestamps (timestamps),
or throttled hit-time refreshing (touchIfStale) across Linux, macOS, and Windows.
Details#
On GNU Linux and Darwin, operations delegate to silk.platform.native.file. On x86-64 MSVC
Windows, operations delegate to silk.platform.windows.file_time (GetFileAttributesExW,
GetFileInformationByHandleEx with FileBasicInfo, and SetFileTime opened with
FILE_WRITE_ATTRIBUTES and full sharing). On hosts without native file timestamps (such as
WASI, bare WebAssembly, or libc-free builds), queries return None and updates are no-ops.
Import as FileTime with import silk.system.file_time as FileTime.
Public declarations: 8.
FileTimestamp#
pub struct FileTimestampOne file timestamp as whole Unix seconds and subsecond nanoseconds.
Field seconds#
pub seconds: i64Whole seconds since 1970-01-01T00:00:00Z.
Field nanoseconds#
pub nanoseconds: u32Nanoseconds after seconds, in the range 0 through 999999999.
Implementation Copy for FileTimestamp#
impl Copy for FileTimestampFileTimestamps#
pub struct FileTimestampsBoth modification and status-change timestamps of a host file or directory.
Field modified#
pub modified: FileTimestampLast data modification time (mtime on POSIX, LastWriteTime on Windows).
Field changed#
pub changed: FileTimestampLast metadata or data change time (ctime on POSIX, ChangeTime on Windows).
Implementation Copy for FileTimestamps#
impl Copy for FileTimestampsFileMeta#
pub struct FileMetaLogical byte length, whole-second modification time, and directory flag read in one lookup.
Field bytes#
pub bytes: u64Logical byte length for files, or zero for directories.
Field modifiedSeconds#
pub modifiedSeconds: i64Whole-second last modification time since 1970-01-01T00:00:00Z.
Field isDirectory#
pub isDirectory: boolTrue when the entry is a directory.
Implementation Copy for FileMeta#
impl Copy for FileMetameta#
pub effect fn meta(path: &Path) -> Option<FileMeta>Returns the logical size, modification time, and directory flag of path in one host lookup,
or None when the path does not exist or the host has no native metadata API.
timestamps#
pub effect fn timestamps(path: &Path) -> Option<FileTimestamps>Returns both the modification (mtime) and status-change (ctime / ChangeTime) timestamps
of path, or None when the path cannot be queried or the host has no native timestamp API.
modifiedSeconds#
pub effect fn modifiedSeconds(path: &Path) -> Option<i64>Returns the modification time of path in whole Unix seconds, or None when unavailable.
setModifiedSeconds#
pub effect fn setModifiedSeconds(path: &Path, seconds: i64) -> boolSets the access and modification times of path to whole Unix seconds. Returns true when
the update succeeded, or false when the path could not be updated or the host has no native
timestamp API.
touchIfStale#
pub effect fn touchIfStale(path: &Path, intervalSeconds: i64) -> ()Refreshes the modification time of path to the current system time when its existing
modification time is at least intervalSeconds old. Best effort: errors are ignored.
Category: System.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.