Expand description
Section-relative paths and containment: the one implementation.
Level authors declare paths, not locations. A fixture, a requirement, a start
directory and a cd rule all speak the same vocabulary, and all of them go through
this module, so a level can never disagree with itself about where it lives, nor
reach outside the workspace the game owns by way of .., an absolute path or a
symlinked parent.
Two different jobs live here:
- Declared paths (
RelPath,resolve_within): strict. Anything that is not a plain relative path, or that passes through a symlink, is rejected. - Observed paths (
normalize_lexically,soft_canonicalize): lenient. They describe where the player is or is going, which may not exist yet, and they never fail.
Structs§
- RelPath
- A declared path that is relative to a section root and cannot leave it.
Enums§
- Containment
Error - A declared path does not stay inside the root it is resolved against.
- Path
Error - Why a declared path was refused as a plain relative path.
Functions§
- normalize_
lexically - Resolve
.and..textually, the waycd -Ldoes for the logical$PWD. - resolve_
within - Resolve a declared path against
root, refusing to escape it. - same_
path - True when two paths name the same location: both are soft-canonicalized first, so a
path through a symlinked ancestor (macOS
/tmp) equals its canonical spelling and a directory that does not exist yet can still be compared. - soft_
canonicalize - Canonicalize the longest existing prefix of
pathand append the rest.