steady-fs
Small, boring, reliable filesystem helpers for Rust CLI tools and developer apps.
steady-fs does not replace std::fs. It wraps common error-prone filesystem workflows into safer, clearer helpers.
The crate is intentionally small. It currently focuses on common file and directory operations used by CLI tools, build scripts, code generators, and developer apps.
For more task-oriented snippets, see the steady-fs cookbook. Runnable examples live in examples/.
Before
write?;
Problems:
- parent directory may not exist
- crash can leave partial file
- overwrite behavior is easy to forget
- error may lack useful path context
After
use *;
atomic_write
.create_parent_dirs
.backup_existing
.write?;
API
use *;
ensure_dir?;
clean_dir.run?;
atomic_write
.create_parent_dirs
.backup_existing
.backup_suffix
.dry_run
.write?;
copy_file
.create_parent_dirs
.overwrite
.backup_existing
.dry_run
.run?;
move_file
.create_parent_dirs
.overwrite
.backup_existing
.dry_run
.fallback_copy_delete
.run?;
Features
atomic_writeensure_dirclean_dircopy_filemove_file- backup-before-overwrite
- dry-run mode
- path-aware errors
Examples
Run the example programs with Cargo:
Notes
atomic_write writes through a temporary file in the destination directory and persists it to the final path. It avoids promising perfect crash-proof behavior on every filesystem.
clean_dir removes the contents of a directory while leaving the directory itself in place. It refuses obviously dangerous paths such as roots, ., and paths containing ...
copy_file and move_file operate on files only. They do not recursively copy or move directories.
Non-goals
- Not a framework.
- Not async-first.
- Not a virtual filesystem.
- Not a config library.
- Not a directory watcher.
- Not a globbing or walking crate.
- Not a replacement for
std::fs.
Status
Early implementation. The API is useful, but still pre-1.0 and expected to stay conservative.