filetime

Read and set file access and modification timestamps in a platform-agnostic way in Rust.

Library
Cargo
v0.2.29
131stars
MIT/Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity16
Maintenance0
Community76
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture82
Code Quality84
Innovation58
Learning Curve95

filetime is a small, long-established Rust helper library for inspecting and setting the various timestamps of files. It abstracts away cross-platform differences in where timestamps live, what they are called, and how to convert them, giving you a single platform-independent FileTime representation for access, modification, and creation times.

Historically this crate filled a gap in the standard library, and with over 320 million downloads it remains one of the most widely depended-on crates in the ecosystem (notably used by build tools and archivers). Its README now notes that modern Rust offers std::fs::FileTimes and File::set_times, so new code can often rely on std — but filetime continues to serve the enormous body of existing dependents.

What You Get

  • A platform-independent FileTime type for representing file timestamps
  • Functions to read access, modification, and creation times from file metadata
  • Functions to set a file’s access and modification times, with symlink-aware variants
  • Consistent behavior across Unix, Windows, Redox, and WASM targets
  • An optional second-resolution emulation mode for debugging HFS-like filesystems

Common Use Cases

  • Preserving original mtimes when extracting or copying files in an archiver or build tool
  • Setting timestamps on generated files to control incremental-build freshness
  • Reading precise file timestamps in a cross-platform way
  • Emulating second-only timestamp resolution to reproduce filesystem-specific bugs

Under The Hood

Architecture - The crate exposes a small public API in lib.rs centered on the FileTime struct and free functions like set_file_times, set_symlink_file_times, and metadata accessors. Platform specifics are isolated behind cfg-selected modules — unix/, windows.rs, redox.rs, and wasm.rs — chosen via cfg-if, so the public surface stays identical while each backend calls the appropriate OS syscall (e.g. utimensat/utimes on Unix, SetFileTime on Windows).

Tech Stack - Pure Rust (edition 2018, MSRV 1.75). Its only always-on dependency is cfg-if; on Unix it additionally uses libc for the timestamp syscalls. tempfile is used for tests. A build-time cfg (emulate_second_only_system) enables the second-rounding debug mode.

Code Quality - Mature and battle-tested: nearly 200 commits from 53 contributors over a decade, with tests exercising the read/set round-trips. The cfg-gated backend split keeps unsafe FFI localized per platform. The library is intentionally minimal and stable rather than actively evolving.

API Design - Deliberately tiny and obvious: a single value type and a handful of well-named functions, with symlink-following and non-following variants clearly distinguished. There is essentially no learning curve for anyone who has used std::fs, which is exactly why it saw such broad adoption before std gained equivalent APIs.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search