Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case-Sensitivity For Windows Drive Letters #70

Closed
jnhyatt opened this issue Sep 9, 2020 · 3 comments
Closed

Case-Sensitivity For Windows Drive Letters #70

jnhyatt opened this issue Sep 9, 2020 · 3 comments
Assignees
Labels
available on master Fix is done on master branch, issue closed on next release bug Something isn't working
Milestone

Comments

@jnhyatt
Copy link
Contributor

jnhyatt commented Sep 9, 2020

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.

@gulrak gulrak self-assigned this Sep 10, 2020
@gulrak gulrak added the bug Something isn't working label Sep 10, 2020
@gulrak
Copy link
Owner

gulrak commented Sep 10, 2020

Good catch, I'll look into it.

@gulrak gulrak added this to the v1.3.6 milestone Sep 16, 2020
@gulrak
Copy link
Owner

gulrak commented Oct 5, 2020

It took me some time to decide how to tackle this. In the end, my take is to make the comparison for the root name on Windows (drive letter) case insensitive. As this is in part correlating with the different fs::path::compare() rules from LWG 2936, I started implementing an option to enable that one as well, but the drive letter case insensitivity is not part of that option, so should be active starting from v1.3.6 if there are no objections with that solution.

I plan to keep LWG_2936_BEHAVIOUR disabled by default in v1.3.6, but I either enable it by default on v1.4.0 or at least when C++20 is found.

gulrak added a commit that referenced this issue Oct 5, 2020
@gulrak gulrak added the available on master Fix is done on master branch, issue closed on next release label Oct 6, 2020
@gulrak
Copy link
Owner

gulrak commented Oct 10, 2020

Released with v1.3.6

@gulrak gulrak closed this as completed Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
available on master Fix is done on master branch, issue closed on next release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants