[PATCH] D67166: Win: handle \\?\UNC\ prefix in realPathFromHandle (PR43204)
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 02:09:19 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371035: Win: handle \\?\UNC\ prefix in realPathFromHandle (PR43204) (authored by hans, committed by ).
Herald added a subscriber: kristina.
Changed prior to commit:
https://reviews.llvm.org/D67166?vs=218748&id=218861#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67166/new/
https://reviews.llvm.org/D67166
Files:
llvm/trunk/lib/Support/Windows/Path.inc
Index: llvm/trunk/lib/Support/Windows/Path.inc
===================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc
+++ llvm/trunk/lib/Support/Windows/Path.inc
@@ -371,13 +371,19 @@
if (std::error_code EC = realPathFromHandle(H, Buffer))
return EC;
- const wchar_t *Data = Buffer.data();
+ // Strip the \\?\ prefix. We don't want it ending up in output, and such
+ // paths don't get canonicalized by file APIs.
+ wchar_t *Data = Buffer.data();
DWORD CountChars = Buffer.size();
- if (CountChars >= 4) {
- if (0 == ::memcmp(Data, L"\\\\?\\", 8)) {
- CountChars -= 4;
- Data += 4;
- }
+ if (CountChars >= 8 && ::memcmp(Data, L"\\\\?\\UNC\\", 16) == 0) {
+ // Convert \\?\UNC\foo\bar to \\foo\bar
+ CountChars -= 6;
+ Data += 6;
+ Data[0] = '\\';
+ } else if (CountChars >= 4 && ::memcmp(Data, L"\\\\?\\", 8) == 0) {
+ // Convert \\?\c:\foo to c:\foo
+ CountChars -= 4;
+ Data += 4;
}
// Convert the result from UTF-16 to UTF-8.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67166.218861.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190905/81d13c16/attachment-0001.bin>
More information about the llvm-commits
mailing list