Expand description
Disk-aware resolution: given a loaded HookConfig plus a game
directory and a scratch/temp directory, decide what should happen to a
given rel_key for reads, writes, and deletes, including staging
patched replacement files and seeding write targets.
This is deliberately an explicit, constructible type rather than a set of free functions over hidden global state. Two very different consumers need it:
supreme_hook_proxy(the DLL): oneHookResolver, loaded lazily the first time the game probes a magic trigger path, then reused for the rest of the process’s life.- anything else that wants to know “what would happen to this path” without injecting into the game at all, e.g. a launcher page that reads/writes a game file and wants mod redirection to apply exactly as it would in-game.
Each consumer owns its own lifecycle/caching policy on top of this; the type itself has no global state and no opinion on when it should be constructed.
Structs§
- Hook
Resolver - Owns a merged
HookConfigplus the two directories every resolution needs: the game’s root directory (to reconstruct original paths) and a scratch directory (to stage patched replacement files). - Managed
File Spec - One remote-backed managed file declared by a
RuleTarget::Managedrule. A mod’smod.jsonnames the file (literal glob), its local path, the URL whose body is the file content, an optional push URL for game writes, and the auto-refresh cadence, the proxy DLL’s generic managed-file engine consumes exactly this, with no per-mod knowledge inside the DLL.
Functions§
- compute_
target_ path - Computes the full target path for a redirected file. Returns
Noneif the rule has notargetconfigured, there’s nothing to compute a path against. - is_
write_ operation - Determines whether a file open operation intends to write or create.
- managed_
file_ specs - Collects every
RuleTarget::Managedrule from the loaded config, in config order. Relativelocalpaths are resolved againstgame_direxactly likeHookResolver::loaddoes, so this accepts either a loaded resolver’s config (absolute) or a raw authored one (relative). Rules whose glob is not literal are skipped here, a wildcard glob cannot name the single file a remote URL provides, andcrate::mod_config::ModConfig::validatealready rejects them with a proper error at load time; this scan just stays defensive. - seed_
target_ file - Seeds a sibling temporary file first, then atomically creates a hard link
at
target_path. Other writers only see a complete copy, and linking does not overwrite a target another writer created. The temporary file is removed after the link is created (or after any error). Both paths are in the same directory, so they are on the same volume. A filesystem that cannot create a hard link fails the seed rather than exposing a partial target or modifying the original.