[libcxx-commits] [PATCH] D91170: [15/N] [libcxx] Implement the canonical function for windows
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 13 03:45:25 PST 2020
mstorsjo updated this revision to Diff 305082.
mstorsjo added a reviewer: amccarth.
mstorsjo added a comment.
Rebased on top of updated patches.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91170/new/
https://reviews.llvm.org/D91170
Files:
libcxx/src/filesystem/operations.cpp
Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -854,6 +854,21 @@
if (hold.get() == nullptr)
return err.report(capture_errno());
return {hold.get()};
+#elif defined(_LIBCPP_WIN32API)
+ wchar_t ret[MAX_PATH];
+ detail::WinHandle h(p.c_str(), FILE_READ_ATTRIBUTES, 0);
+ if (!h)
+ return err.report(detail::make_windows_error(GetLastError()));
+ if (!GetFinalPathNameByHandleW(h, ret, MAX_PATH,
+ FILE_NAME_NORMALIZED | VOLUME_NAME_DOS))
+ return err.report(detail::make_windows_error(GetLastError()));
+ if (!wcsncmp(ret, L"\\\\?\\", 4)) {
+ if (ret[5] == ':') // \\?\X: -> X:
+ return {&ret[4]};
+ if (!wcsncmp(&ret[4], L"UNC\\", 4)) // \\?\UNC\server -> \\server
+ return {std::wstring(L"\\\\") + &ret[8]};
+ }
+ return {ret};
#else
char buff[PATH_MAX + 1];
char* ret;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91170.305082.patch
Type: text/x-patch
Size: 998 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201113/125c70db/attachment.bin>
More information about the libcxx-commits
mailing list