Use SHGetKnownFolderPath, to avoid MAX_PATH limitation

Change-Id: If7e70453bd67ec874fc06af7cd53a8c410a24e52
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163912
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-02-25 19:17:53 +06:00
parent 2468fe5d91
commit 5e134896f3

View file

@ -1331,14 +1331,15 @@ OUString ModelData_Impl::GetRecommendedDir( const OUString& aSuggestedDir )
#ifdef _WIN32
if( !bIsInTempPath )
{
wchar_t sPath[MAX_PATH+1];
HRESULT hRes = SHGetFolderPathW( nullptr, CSIDL_INTERNET_CACHE, nullptr, SHGFP_TYPE_CURRENT, sPath );
PWSTR sPath;
HRESULT hRes = SHGetKnownFolderPath(FOLDERID_InternetCache, 0, nullptr, &sPath);
if( SUCCEEDED(hRes) )
{
OUString sTempINetFiles;
if( osl::FileBase::getFileURLFromSystemPath(OUString(o3tl::toU(sPath)), sTempINetFiles) == osl::FileBase::E_None )
bIsInTempPath = !sTempINetFiles.isEmpty() && sLocationURL.startsWith( sTempINetFiles );
}
CoTaskMemFree(sPath);
}
#endif
// Suggest somewhere other than the system's temp directory