summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2018-02-21 09:27:25 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2018-02-22 20:23:39 +0100
commit50bf4eec6ff3cb3db23484331965f2e32cb0b5bc (patch)
tree3a6972948eabccc59f1d1df9907b38bd5cf22ff1 /sal
parent5ec76e598899a9939fa1f3bceab1caae5dfd1a67 (diff)
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/50079 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/w32/file_dirvol.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index c3848e5662bc..929916965777 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -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;