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

Windows: implement getCorrectCasing #9435

Closed

Conversation

laszlocsomor
Copy link
Contributor

Implement getCorrectCasing: a function that
normalizes a path and returns the case-correct
version of it.

See #8799

Implement getCorrectCasing: a function that
normalizes a path and returns the case-correct
version of it.

See bazelbuild#8799
@laszlocsomor laszlocsomor changed the title WIP: Windows: implement getCorrectCasing Windows: implement getCorrectCasing Sep 25, 2019
@laszlocsomor laszlocsomor marked this pull request as ready for review September 25, 2019 08:09
@@ -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]));
}
}

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -781,5 +781,46 @@ bool GetCwd(std::wstring* result, DWORD* err_code) {
}
}

std::wstring GetCorrectCasing(const std::wstring& abs_path, bool with_unc) {
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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;
Copy link
Member

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?

Copy link
Member

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment.

@laszlocsomor
Copy link
Contributor Author

Thanks for the quick and thorough review!

@bazel-io bazel-io closed this in 06d2f6d Sep 25, 2019
@laszlocsomor laszlocsomor deleted the get-correct-casing branch September 25, 2019 09:38
bazel-io pushed a commit that referenced this pull request Oct 31, 2019
*** 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants