12#include <osl/file.hxx>
15#define WIN32_LEAN_AND_MEAN
23OUString UNCToDavURL(LPCWSTR sUNC)
26 auto bufURL(std::make_unique<
wchar_t[]>(nSize));
27 DWORD nResult = DavGetHTTPFromUNCPath(sUNC, bufURL.get(), &nSize);
28 if (nResult == ERROR_INSUFFICIENT_BUFFER)
30 bufURL = std::make_unique<wchar_t[]>(nSize);
31 nResult = DavGetHTTPFromUNCPath(sUNC, bufURL.get(), &nSize);
34 return nResult == ERROR_SUCCESS
35 ? ::rtl::Uri::encode(OUString(o3tl::toU(bufURL.get())), rtl_UriCharClassUric,
36 rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8)
44bool IsMappedWebDAVPath([[maybe_unused]]
const OUString& rURL, [[maybe_unused]] OUString* pRealURL)
47 if (rURL.startsWithIgnoreAsciiCase(
"file:"))
50 if (osl::FileBase::getSystemPathFromFileURL(rURL, aSystemPath) == osl::FileBase::E_None)
53 auto bufUNC(std::make_unique<
char[]>(nSize));
54 DWORD nResult = WNetGetUniversalNameW(o3tl::toW(aSystemPath.getStr()),
55 UNIVERSAL_NAME_INFO_LEVEL, bufUNC.get(), &nSize);
56 if (nResult == ERROR_MORE_DATA)
58 bufUNC = std::make_unique<char[]>(nSize);
59 nResult = WNetGetUniversalNameW(o3tl::toW(aSystemPath.getStr()),
60 UNIVERSAL_NAME_INFO_LEVEL, bufUNC.get(), &nSize);
62 if (nResult ==
NO_ERROR || nResult == ERROR_BAD_DEVICE)
65 if (nResult == ERROR_BAD_DEVICE)
66 aReq.lpRemoteName =
const_cast<LPWSTR
>(o3tl::toW(aSystemPath.getStr()));
69 auto pInfo =
reinterpret_cast<LPUNIVERSAL_NAME_INFOW
>(bufUNC.get());
70 aReq.lpRemoteName = pInfo->lpUniversalName;
73 auto bufInfo(std::make_unique<
char[]>(nSize));
74 LPWSTR pSystem =
nullptr;
75 nResult = WNetGetResourceInformationW(&aReq, bufInfo.get(), &nSize, &pSystem);
76 if (nResult == ERROR_MORE_DATA)
78 bufInfo = std::make_unique<char[]>(nSize);
79 nResult = WNetGetResourceInformationW(&aReq, bufInfo.get(), &nSize, &pSystem);
83 LPNETRESOURCEW pInfo =
reinterpret_cast<LPNETRESOURCEW
>(bufInfo.get());
84 if (wcscmp(pInfo->lpProvider, L
"Web Client Network") == 0)
87 *pRealURL = UNCToDavURL(aReq.lpRemoteName);