Index: libcxx/src/filesystem/operations.cpp =================================================================== --- libcxx/src/filesystem/operations.cpp +++ libcxx/src/filesystem/operations.cpp @@ -780,6 +780,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::capture_last_error()); + if (!GetFinalPathNameByHandleW(h, ret, MAX_PATH, + FILE_NAME_NORMALIZED | VOLUME_NAME_DOS)) + return err.report(detail::capture_last_error()); + 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;