Use SHGetKnownFolderPath to avoid MAX_PATH limitation

Change-Id: Icba230fedc9e6071d3817454f55d4533727e3aa2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163916
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-02-25 19:22:43 +06:00
parent 5e134896f3
commit 276f8ef880

View file

@ -183,13 +183,13 @@ OUString UpdateCheckConfig::getAllUsersDirectory()
OUString aRet;
#ifdef _WIN32
WCHAR szPath[MAX_PATH];
if (TRUE == SHGetSpecialFolderPathW(nullptr, szPath, CSIDL_COMMON_DOCUMENTS, true))
PWSTR szPath = nullptr;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_PublicDocuments, KF_FLAG_CREATE, nullptr, &szPath)))
{
aRet = o3tl::toU(szPath);
osl::FileBase::getFileURLFromSystemPath( aRet, aRet );
}
CoTaskMemFree(szPath);
#else
osl::FileBase::getTempDirURL(aRet);
#endif