Patch attached, and discussed with Caolán. I've detected a bit of duplicate code in different files, I'll try to make them use this function in the future.
-- Francois Tigeot
>From 0f396782dee612dabea9ee9830f564d7815e464f Mon Sep 17 00:00:00 2001 From: Francois Tigeot <ftig...@wolfpond.org> Date: Wed, 13 Jul 2011 11:20:10 +0200 Subject: [PATCH] Simplify osl_getTempDirURL() Do not return different values depending on the platform --- sal/osl/unx/tempfile.c | 48 ++++++++++++------------------------------------ 1 files changed, 12 insertions(+), 36 deletions(-) diff --git a/sal/osl/unx/tempfile.c b/sal/osl/unx/tempfile.c index 862aff2..a907684 100644 --- a/sal/osl/unx/tempfile.c +++ b/sal/osl/unx/tempfile.c @@ -49,53 +49,29 @@ #include "file_url.h" #endif -/*****************************************************************/ -/* osl_getTempFirURL */ -/*****************************************************************/ - oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** pustrTempDir ) { -#ifdef MACOSX + oslFileError error; + /* described in environ(7) */ const char *pValue = getenv( "TMPDIR" ); - /* If TMPDIR environment variable is not set, use "/tmp" instead - of P_tmpdir because its value is "/var/tmp" and it is not - deleted on system start up */ - if ( !pValue ) - pValue = "/tmp"; -#else - - const char *pValue = getenv( "TEMP" ); + if ( !pValue || !access(pValue, R_OK | W_OK | X_OK)) + pValue = getenv( "TEMP" ); - if ( !pValue ) + if ( !pValue || !access(pValue, R_OK | W_OK | X_OK)) pValue = getenv( "TMP" ); -#if defined(NETBSD) - if ( !pValue ) - pValue = _PATH_TMP; -#else - if ( !pValue ) - pValue = P_tmpdir; -#endif - - if ( !pValue ) + if ( !pValue || !access(pValue, R_OK | W_OK | X_OK)) pValue = "/tmp"; -#endif /* MACOSX */ - if ( pValue ) - { - oslFileError error; - rtl_uString *ustrTempPath = NULL; + rtl_uString *ustrTempPath = NULL; - rtl_string2UString( &ustrTempPath, pValue, strlen( pValue ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - OSL_ASSERT(ustrTempPath != NULL); - error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); - rtl_uString_release( ustrTempPath ); + rtl_string2UString( &ustrTempPath, pValue, strlen( pValue ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); + OSL_ASSERT(ustrTempPath != NULL); + error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir ); + rtl_uString_release( ustrTempPath ); - return error; - } - else - return osl_File_E_NOENT; + return error; } /****************************************************************** -- 1.7.4.1
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice