summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-12 14:40:13 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-12 18:20:30 +0100
commit3380163bc0fb9dab7f289cc36b0eeb0c9b3ddaa9 (patch)
tree28b6c070d4287a632d16f433bc4d9b03328f7705 /sal
parentbeeed387732f95501b06b5462d450517422b18ba (diff)
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@googlemail.com> Tested-by: Jenkins
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/tempfile.cxx5
1 files changed, 4 insertions, 1 deletions
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 );