filepath
filepath copied to clipboard
normalise should eliminate parent directories on Windows
Windows seems to interpret paths differently than on POSIX systems.
- On POSIX,
/sym/link/../foorefers to/target/dir/../foo ≡ /target/foo(..expands after dereferencing). - On Windows,
C:\sym\link\..\fooalways refers toC:\sym\foo(..expands before dereferencing).
This feature would be useful to have because if you want to pass in extended-length paths (the \\?\ prefix) you have to normalize the path before adding the prefix, otherwise the Windows API will interpret .. literally.
What if you do the Windows style path on a Mingw shell - does it expand before or after dereferencing?
Tried it in the MSYS shell (that one that comes with Stack):
C:\sym\link\..\fooexpands before deref.C:/sym/link/../fooexpands before deref./c/sym/link/../fooexpands after deref.
That's disturbingly inconsistent... I guess you need two separate methods, one which expands .. and one which doesn't.
@Rufflewind is this observed behavior or is there something in windows documentation suggesting this is behavior that can be relied upon?
I have not seen documentation around it but I haven't really tried looking per se. It's just a quirk I observed when trying to test native symbolic links on Windows.