Skip to main content

Module layout

Module layout 

Source
Expand description

Directory layout and profile lifecycle (named r2modman profiles; client mode). Directory layout and profile lifecycle.

Profiles live at <base>/<game>/profiles/<name>/, matching r2modman so a profile directory produced here works when copied into r2modman’s data dir. The caller owns base (platform/path discovery stays outside the engine).

§Errors

Every fallible function in this module returns Error::Profile and nothing else. Underlying IO failures are wrapped with the offending path rather than surfaced as Error::Io, so a caller can render the message directly and does not need to match other variants or prepend a path itself.

Every function taking a profile name calls validate_name before touching the filesystem, so a name containing a separator, NUL, ., or .. is rejected before it can escape the profiles directory. Individual functions document only the conditions beyond that shared contract.

Enums§

BadProfile
Why a profile name cannot be used.

Functions§

clear_selection
Removes the persisted selection, returning to game-directory mode. Absent is not an error.
create
Creates a new, empty profile directory. Errors if it already exists so a create never silently adopts an existing profile.
delete
Removes a profile directory and everything under it, and clears the stored selection if it named this profile.
duplicate
Duplicates a profile directory (recursive copy) under a new name.
list
Lists profile names (immediate subdirectories) for a game, sorted. A missing profiles directory yields an empty list.
profile_dir
A single profile directory: <base>/<game>/profiles/<name>.
profiles_dir
The profiles directory for a game: <base>/<game>/profiles.
read_selection
The persisted selection, or None when absent, empty, or unreadable.
rename
Renames a profile, carrying the stored selection across if it named from.
require_profile
The directory of an existing profile, classifying why not when there is none.
select_profile
Chooses the active profile from a caller’s override and the persisted selection. Pure, so the precedence is testable without touching disk.
selection_path
The path of the persisted profile selection.
use_profile
Selects name as the active profile, refusing one that does not exist.
validate_name
Rejects a profile name that is empty, a path component (./..), or that contains a path separator or NUL — so a name can never escape the profiles directory.
write_selection
Persists name as the selected profile.