[Libreoffice-commits] core.git: sal/osl

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Thu Feb 22 19:24:03 UTC 2018


 sal/osl/w32/file_dirvol.cxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 50bf4eec6ff3cb3db23484331965f2e32cb0b5bc
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Wed Feb 21 09:27:25 2018 +0100

    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 at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

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;


More information about the Libreoffice-commits mailing list