Module fs

Module fs 

Source
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

OperationPurposeAtomicity
cleanup_pathRemove files and directories with deferred-delete fallbackBest-effort
replace_directorySwap directories with rollback and cross-volume fallbackTransactional
atomic_writeWrite files atomically via temp file + renameAll-or-nothing
extract_archiveExtract archives with path traversal protectionRollback 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§

ArchiveKind
Archive formats supported by WinBrew’s extraction layer.
FsError

Functions§

atomic_write
Writes contents to path through temp_path and publishes the result atomically.
atomic_write_toml_temp
Writes contents to a PID-scoped TOML temp file and atomically publishes it.
backup_path_for
Returns the sibling .old backup path used during directory replacement.
cleanup_path
Removes path if 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_path with temp_path, removing any existing target first.
replace_directory
Replaces source_dir with target_dir, copying across volumes when rename is not available and rolling back the backup on failure.

Type Aliases§

Result