Expand description
File-system helpers used by Winbrew’s configuration, download, and install flows.
This module provides atomic, transactional filesystem operations with Windows-specific security considerations such as reparse points and hard links.
§Operations
| Operation | Purpose | Atomicity |
|---|---|---|
cleanup_path | Remove files and directories with deferred-delete fallback | Best-effort |
replace_directory | Swap directories with rollback and cross-volume fallback | Transactional |
atomic_write | Write files atomically via temp file + rename | All-or-nothing |
extract_archive | Extract archives with path traversal protection | Rollback on fail |
§Platform Behavior
- Windows: Handles junction points, hard links, and cross-volume copies.
- Unix: Standard POSIX semantics; reparse-point checks are no-ops.
§Example
use std::path::Path;
use winbrew_core::fs::{atomic_write, cleanup_path, replace_directory};
atomic_write(
Path::new("config.toml"),
Path::new("config.toml.tmp"),
b"key = value",
).map_err(|err| *err)?;
replace_directory(Path::new("staging/app"), Path::new("app")).map_err(|err| *err)?;
cleanup_path(Path::new("app.old")).map_err(|err| *err)?;Re-exports§
pub use crate::paths::sevenz_bin_path_from_runtime_root;pub use crate::paths::sevenz_dll_path_from_runtime_root;pub use crate::paths::sevenz_runtime_dir_from_runtime_root;pub use crate::paths::system_sevenz_binary_path;
Modules§
- archive 🔒
- Archive extraction facade.
- cleanup 🔒
- Path cleanup utilities with Windows reparse point awareness.
- error 🔒
- move_
or_ 🔒copy - write 🔒
Enums§
- Archive
Kind - Archive formats supported by WinBrew’s extraction layer.
- FsError
Functions§
- atomic_
write - Writes
contentstopaththroughtemp_pathand publishes the result atomically. - atomic_
write_ toml_ temp - Writes
contentsto a PID-scoped TOML temp file and atomically publishes it. - backup_
path_ for - Returns the sibling
.oldbackup path used during directory replacement. - cleanup_
path - Removes
pathif it exists. - extract_
archive - Extracts an archive into
destination_dir, rejecting entries with invalid paths. - extract_
zip_ archive - Extracts a ZIP archive into the destination directory.
- finalize_
temp_ file - Replaces
final_pathwithtemp_path, removing any existing target first. - replace_
directory - Replaces
source_dirwithtarget_dir, copying across volumes when rename is not available and rolling back the backup on failure.