I work on garbage, a project that touches the filesystem a lot. Because of this, I’d really like to control when and where these filesystem accesses happen.
The Rust standard library has a
fs module, which I expect to exclusively
contain filesystem access primitives. But actually a lot of the functionality
also gets leaked into
In my ideal world,
Path only deals with the data in a path, not its
interaction with the filesystem. So it should never be able to check whether or
not a path exists, for example, or if a path is a symlink. Those
should be delegated to something within
In addition, many of these functions automatically resolve symlinks, without
built-in ways of achieving the same functionality without resolving symlinks, so
I ended up having to fill those in myself. For example, I really just expect
canonicalize to be an in-memory manipulation of path components.
Honestly, I’ve got to give it to Python’s pathlib, which solves the problems I
noted above. It splits the path API into
PurePath, the latter of
which does not make any IO accesses. It also provides non-symlink-resolving and
symlink-resolving variants of converting to absolute paths.