-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Windows: implement getCorrectCasing #9435
Conversation
Implement getCorrectCasing: a function that normalizes a path and returns the case-correct version of it. See bazelbuild#8799
@@ -228,4 +230,14 @@ public static boolean deletePath(String path) throws IOException { | |||
throw new IOException(String.format("Cannot delete path '%s': %s", path, error[0])); | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please a comment here that explains what "correct" refers to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/main/native/windows/file.cc
Outdated
@@ -781,5 +781,46 @@ bool GetCwd(std::wstring* result, DWORD* err_code) { | |||
} | |||
} | |||
|
|||
std::wstring GetCorrectCasing(const std::wstring& abs_path, bool with_unc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like an absolute path is required - I don't see this requirement on the Java side. Do I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently the only caller passes with_unc=false, right? Do you have plans to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
wcscpy(result.get(), L"\\\\?\\"); | ||
wcscpy(result.get() + 4, path.c_str()); | ||
result[4] = towupper(result[4]); | ||
wchar_t* start = result.get() + 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of implicit knowledge in this code which makes it hard to read, e.g. where does the 7 come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this from UNC (if so make it conditional)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment.
Thanks for the quick and thorough review! |
*** Reason for rollback *** We must implement path case fixing on top of Skyframe (by requesting DirectoryListingValue), rather than as a JNI method. That way clients get invalidated when a path is renamed such that only the casing changes. *** Original change description *** Windows: implement getCorrectCasing Implement getCorrectCasing: a function that normalizes a path and returns the case-correct version of it. See #8799 Closes #9435. PiperOrigin-RevId: 277688249
Implement getCorrectCasing: a function that
normalizes a path and returns the case-correct
version of it.
See #8799