From 5e134896f35d5c3a194090f2af1b84fbaec8b432 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 25 Feb 2024 19:17:53 +0600 Subject: [PATCH] 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 --- sfx2/source/doc/guisaveas.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 5773fc732ea9..974aef7384d9 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -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