Currently, AbsolutePath::Canonicalize will mostly do nothing for a non-existing path, it will be returned as-is.
Which is mostly fine, but might cause misinterpretation on the user's side: e.g. while myPath.Canonicalize() is okay-ish and follows the spec "canonical if exists", myPath.Canonicalize().Parent is not okay — if myPath doesn't exist then this will not be canonicalized, even if existing.
We should think about this situation, perhaps let's introduce two more methods?
CanonicalIfExists(): AbsolutePath?
CanonicalRecursive(): AbsolutePath — which will essentially do CanonicalIfExists() ?? Parent.CanonicalRecursive() / FileName — e.g. will try to canonicalize existing parent chain whenever possible
Currently,
AbsolutePath::Canonicalizewill mostly do nothing for a non-existing path, it will be returned as-is.Which is mostly fine, but might cause misinterpretation on the user's side: e.g. while
myPath.Canonicalize()is okay-ish and follows the spec "canonical if exists",myPath.Canonicalize().Parentis not okay — ifmyPathdoesn't exist then this will not be canonicalized, even if existing.We should think about this situation, perhaps let's introduce two more methods?
CanonicalIfExists(): AbsolutePath?CanonicalRecursive(): AbsolutePath— which will essentially doCanonicalIfExists() ?? Parent.CanonicalRecursive() / FileName— e.g. will try to canonicalize existing parent chain whenever possible