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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 12 17:21:19 UTC 2021


 sal/osl/unx/tempfile.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 3380163bc0fb9dab7f289cc36b0eeb0c9b3ddaa9
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Feb 12 14:40:13 2021 +0100
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Feb 12 18:20:30 2021 +0100

    Make sure osl_getTempDirURL result doesn't end with / also on unx
    
    This is consistent with what osl_getTempDirURL does on Windows
    This is a blind attempt to fix a part of a failure reported on IRC:
    
      /lode/dev/core/sal/qa/osl/file/osl_File.cxx:486: Assertion
      Test name: osl_FileBase::getAbsoluteFileURL::getAbsoluteFileURL_001_1
      equality assertion failed
      - Expected: file:///var/folders/tj/jl7sh26124n4b94tm541m6xr0000gn/T//relative/file1
      - Actual  : file:///private/var/folders/tj/jl7sh26124n4b94tm541m6xr0000gn/T/relative/file1
      - Assumption is wrong: ResultURL is not equal to expected URL
    
    That "//" in Expected might be because user's TMPDIR ends with /.
    
    Change-Id: I9a9c6e00f63b81dbaf2e8532110dffa58ebe8cc9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110784
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Jenkins

diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx
index 01247ae24fe3..b91d4b6e0ac7 100644
--- a/sal/osl/unx/tempfile.cxx
+++ b/sal/osl/unx/tempfile.cxx
@@ -50,7 +50,10 @@ oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** pustrTempDir )
     if ( !pValue )
         pValue = "/tmp";
 
-    rtl_string2UString( &ustrTempPath, pValue, strlen( pValue ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+    auto nLen = strlen(pValue);
+    while (nLen && pValue[nLen - 1] == '/')
+        --nLen;
+    rtl_string2UString( &ustrTempPath, pValue, nLen, osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
     assert(ustrTempPath);
     error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir );
     rtl_uString_release( ustrTempPath );


More information about the Libreoffice-commits mailing list