Windows case-sensitivity for drive letters is not always interpreted correctly.
To Reproduce:
fs::path path = fs::relative("c:\\dev\\working\\directory\\file.txt");
Assuming the current working directory is C:\dev\working\directory, one would expect path to be file.txt. However, because the second (optional) argument to relative is evaluated as C:\dev\working\directory (capital 'C'), lexically_relative will exit early on its first check and simply return a default-constructed path.
A fix for this specific issue could be to force drive letters to be capital, say, in weakly_canonical. Now, even Windows can't guarantee case-insensitivity for all file names, but I do believe that drive letters are case-insensitive -- for example, I don't think you can have a d: and D: drive mounted simultaneously. Additionally, under MSVC, it appears that path equality checks are completely case-insensitive when using the standard template library's file system implementation. This does not seem to be the case when compiling under any other compiler.
Windows case-sensitivity for drive letters is not always interpreted correctly.
To Reproduce:
fs::path path = fs::relative("c:\\dev\\working\\directory\\file.txt");Assuming the current working directory is
C:\dev\working\directory, one would expectpathto befile.txt. However, because the second (optional) argument torelativeis evaluated asC:\dev\working\directory(capital 'C'),lexically_relativewill exit early on its first check and simply return a default-constructedpath.A fix for this specific issue could be to force drive letters to be capital, say, in
weakly_canonical. Now, even Windows can't guarantee case-insensitivity for all file names, but I do believe that drive letters are case-insensitive -- for example, I don't think you can have ad:andD:drive mounted simultaneously. Additionally, under MSVC, it appears that path equality checks are completely case-insensitive when using the standard template library's file system implementation. This does not seem to be the case when compiling under any other compiler.