Kaydet (Commit) 50bf4eec authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt Kaydeden (comit) Mike Kaganski

Use long path prefix in osl_getFileStatus

When installing an extension e.g., paths can get very long and they
hit the 255 char limit, thus the installation fails.
So we need to prefix the path with the long file name prefix
when its longer than MAX_PATH for windows api calls to succeed.

Change-Id: Ie62644192ba40a9d4802772cd9837fc84fae947a
Reviewed-on: https://gerrit.libreoffice.org/50079Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 5ec76e59
......@@ -1573,9 +1573,16 @@ oslFileError SAL_CALL osl_getFileStatus(
break;
}
OUString sFullPath(pItemImpl->m_pFullPath);
// Prefix long paths, windows API calls expect this prefix
// (only local paths starting with something like C: or D:)
if (sFullPath.getLength() >= MAX_PATH && isalpha(sFullPath[0]) && sFullPath[1] == ':')
sFullPath = "\\\\?\\" + sFullPath;
if ( uFieldMask & osl_FileStatus_Mask_Validate )
{
HANDLE hFind = FindFirstFileW( o3tl::toW(rtl_uString_getStr( pItemImpl->m_pFullPath )), &pItemImpl->FindData );
HANDLE hFind = FindFirstFileW( o3tl::toW(sFullPath.getStr() ), &pItemImpl->FindData );
if ( hFind != INVALID_HANDLE_VALUE )
FindClose( hFind );
......@@ -1635,7 +1642,7 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL )
{
oslFileError error = osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrLinkTargetURL );
oslFileError error = osl_getFileURLFromSystemPath( sFullPath.pData, &pStatus->ustrLinkTargetURL );
if (error != osl_File_E_None)
return error;
......@@ -1647,7 +1654,7 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( !pItemImpl->bFullPathNormalized )
{
::osl::LongPathBuffer< sal_Unicode > aBuffer( MAX_LONG_PATH );
sal_uInt32 nNewLen = GetCaseCorrectPathName( o3tl::toW(rtl_uString_getStr( pItemImpl->m_pFullPath )),
sal_uInt32 nNewLen = GetCaseCorrectPathName( o3tl::toW( sFullPath.getStr() ),
o3tl::toW( aBuffer ),
aBuffer.getBufSizeInSymbols(),
true );
......@@ -1655,11 +1662,12 @@ oslFileError SAL_CALL osl_getFileStatus(
if ( nNewLen )
{
rtl_uString_newFromStr( &pItemImpl->m_pFullPath, aBuffer );
sFullPath = OUString( pItemImpl->m_pFullPath );
pItemImpl->bFullPathNormalized = TRUE;
}
}
oslFileError error = osl_getFileURLFromSystemPath( pItemImpl->m_pFullPath, &pStatus->ustrFileURL );
oslFileError error = osl_getFileURLFromSystemPath( sFullPath.pData, &pStatus->ustrFileURL );
if (error != osl_File_E_None)
return error;
pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment