Description
If you create a link brokenlink
that points to a nonexistent
file and then run canonicalizePath
on brokenlink
, you still get brokenlink
back because the link is dangling. I think it makes more sense to return nonexistent
instead.
Fixing this however, is quite tricky. The reason is that we can't trust realpath
will work correctly on a nonexistent path: on Macs realpath
has strange behavior with nonexistent paths (#23), and on Windows the “realpath”-equivalent (GetFinalPathName
) requires an existing file to even work.
So this means our only option is to implement it using a readlink
(or equivalent). But it may take more than one readlink
calls to make this work, if there are more symbolic link components in the new path, Worse potentially this might loop, so we'd need a cutoff too.
All in all, this is (IMO) a fairly minor thing, but requires a lot of effort and testing to get right.