Paths and Locking
The absolute-POSIX path helpers the sessions use, and the lock they take over the path map.
import {
basename,
dirname,
isPathInside,
joinPath,
normalizePath,
PathLock,
splitPath,
} from "mountx";Both are exported because a driver doing its own path bookkeeping wants the same rules the transports follow — not because a driver has to call them. Every path a driver receives is already normalized.
#Path helpers
Absolute POSIX paths only; .. clamps at the root, so no input can escape upward out of the mount.
splitPath("/a/b"); // ["a", "b"]
normalizePath("/a//b/../c"); // "/a/c"
joinPath("/a", "b"); // "/a/b"
dirname("/a/b"); // "/a"
basename("/a/b"); // "b"
isPathInside("/a/b", "/a"); // true#PathLock
The writer lock over the path map, shared by both transports' sessions. RENAME takes it; READ/WRITE run outside it — the whole point being that bulk I/O never waits on a rename that is not in its way.
#Next
- Driver interface — where those paths arrive.
- Tuning — concurrency, and what the lock costs.