From 3380163bc0fb9dab7f289cc36b0eeb0c9b3ddaa9 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 12 Feb 2021 14:40:13 +0100 Subject: 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 Tested-by: Jenkins --- sal/osl/unx/tempfile.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sal/osl') 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 ); -- cgit