diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-02-15 12:49:30 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-02-15 14:34:37 +0100 |
commit | 181fc61c4cce5192e57657c313ee7fa4f640fb69 (patch) | |
tree | 3174e1650c65b16075024480d5cfbcfc5d621a8e /sal/osl | |
parent | 96be489048ca97bfc07d4aa252675b76dfca73a2 (diff) |
Reuse known length of the temp dir path
And make this code a bit more C++-ish.
Change-Id: I59d4f46698ad4606f09e6ffcae8f205798b427ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110912
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/w32/tempfile.cxx | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx index 5424bfbde077..a4c272e57768 100644 --- a/sal/osl/w32/tempfile.cxx +++ b/sal/osl/w32/tempfile.cxx @@ -21,6 +21,7 @@ #include <osl/file.h> #include <o3tl/char16_t2wchar_t.hxx> +#include <rtl/ustring.hxx> #include "file-impl.hxx" #include "file_error.hxx" @@ -227,16 +228,12 @@ oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir) } else if ( nLength ) { - rtl_uString *ustrTempPath = nullptr; - if ( '\\' == lpBuffer[nLength-1] ) - lpBuffer[nLength-1] = 0; - - rtl_uString_newFromStr( &ustrTempPath, o3tl::toU(lpBuffer) ); + --nLength; - error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); + const OUString ustrTempPath(o3tl::toU(lpBuffer), static_cast<sal_Int32>(nLength)); - rtl_uString_release( ustrTempPath ); + error = osl_getFileURLFromSystemPath(ustrTempPath.pData, pustrTempDir); } else error = oslTranslateFileError( GetLastError() ); |