Open P-E-Meunier opened 3 years ago
Can you provide a concrete use case?
To me it seems a bit unusual: where adding to an existing path addresses subtrees, strip_prefix
refers to an entirely different subtree of the filesystem, where this crate's goal is to prevent confusion between filesystem subtrees.
In Pijul, we need paths relative to the root of a repository: specifically, when we have a repository in /path/to/my/repo
, the current directory is /path/to/my/repo/a/b/c
, and we want to add ../d/../f
, we need to know that the file to add, relative to the root of the repository, is a/f
.
Now, this wasn't a problem on Unix, since the root of the repository is always in canonical form, so I was canonicalizing paths, and then stripping off the root of the repository.
Unfortunately, that doesn't really work on Windows, where canonicalize
returns an "extended syntax path", which is almost never used by end users directly, and almost always as a result of calling canonicalize
.
I understand that this is a strange use case, since we're essentially implementing a filesystem inside another filesystem, and we can totally do without strip_prefix
if you don't think this is relevant (some documentation about that design choice would be useful though).
Having a checked version of
strip_prefix
, guaranteed to happen only between two canonical paths, would be very useful.