diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-11-19 14:51:29 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-11-19 16:33:14 +0100 |
commit | bb05f1128fa073b35788a73ff6e8a5d8366b7710 (patch) | |
tree | 82f0dc5f377a04cfd27b83b3359fecf720ef5d16 /sal | |
parent | 7fe2a3fd370049d7599c301d2af71ca61fec1431 (diff) |
Remove obsolete osl_searchPath_impl
(obsoleting cid#983584)
Change-Id: Icbf25bd364fdabb208abe201ddc146daa60f9b62
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/file_url.cxx | 9 | ||||
-rw-r--r-- | sal/osl/unx/file_url.hxx | 8 | ||||
-rw-r--r-- | sal/osl/unx/process.cxx | 119 |
3 files changed, 55 insertions, 81 deletions
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 6b1cca2fffb5..1ce642453806 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -621,9 +621,7 @@ oslFileError osl_getAbsoluteFileURL(rtl_uString* ustrBaseDirURL, rtl_uString* u return oslFileError(rc); } -namespace -{ - +namespace osl { namespace detail { /********************************************* No separate error code if unicode to text conversion or getenv fails because for the @@ -642,7 +640,10 @@ namespace return bfound; } +} } +namespace +{ /********************************************* No separate error code if unicode to text conversion or getcwd fails because for the @@ -689,7 +690,7 @@ oslFileError osl_searchFileURL(rtl_uString* ustrFilePath, rtl_uString* ustrSearc rtl::OUString result; if (find_in_searchPath(file_path, ustrSearchPath, result) || - find_in_PATH(file_path, result) || + osl::detail::find_in_PATH(file_path, result) || find_in_CWD(file_path, result)) { rtl::OUString resolved; diff --git a/sal/osl/unx/file_url.hxx b/sal/osl/unx/file_url.hxx index d087638af5f4..eceaabd4c651 100644 --- a/sal/osl/unx/file_url.hxx +++ b/sal/osl/unx/file_url.hxx @@ -22,6 +22,8 @@ #include "osl/file.h" +namespace rtl { class OUString; } + oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath); oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL); @@ -30,6 +32,12 @@ int UnicodeToText(char * buffer, size_t bufLen, const sal_Unicode * uniText, sal int TextToUnicode(const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size); +namespace osl { namespace detail { + +bool find_in_PATH(const rtl::OUString& file_path, rtl::OUString& result); + +} } + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx index 57af42be7f59..537b1eb73850 100644 --- a/sal/osl/unx/process.cxx +++ b/sal/osl/unx/process.cxx @@ -50,6 +50,7 @@ #include <osl/conditn.h> #include <osl/thread.h> #include <osl/file.h> +#include <osl/file.hxx> #include <osl/signal.h> #include <rtl/alloc.h> #include <sal/log.hxx> @@ -94,69 +95,6 @@ struct ProcessData static oslProcessImpl* ChildList; static oslMutex ChildListMutex; -/****************************************************************************** - Deprecated - Old and buggy implementation of osl_searchPath used only by - osl_psz_executeProcess. - A new implementation is in file_path_helper.cxx - *****************************************************************************/ - -static oslProcessError SAL_CALL osl_searchPath_impl(const sal_Char* pszName, - sal_Char *pszBuffer, sal_uInt32 Max) -{ - sal_Char path[PATH_MAX + 1]; - sal_Char *pchr; - - path[0] = '\0'; - - OSL_ASSERT(pszName != NULL); - - if ( pszName == 0 ) - { - return osl_Process_E_NotFound; - } - - if ( (pchr = getenv("PATH")) != 0 ) - { - sal_Char *pstr; - - while (*pchr != '\0') - { - pstr = path; - - while ((*pchr != '\0') && (*pchr != ':')) - *pstr++ = *pchr++; - - if ((pstr > path) && ((*(pstr - 1) != '/'))) - *pstr++ = '/'; - - *pstr = '\0'; - size_t reminder = PATH_MAX - strlen(path); - if(reminder > strlen(pszName)) - { - strncat(path, pszName, reminder); - - if (access(path, 0) == 0) - { - char szRealPathBuf[PATH_MAX + 1] = ""; - - if( NULL == realpath(path, szRealPathBuf) || (strlen(szRealPathBuf) >= (sal_uInt32)Max)) - return osl_Process_E_Unknown; - - strcpy(pszBuffer, path); - - return osl_Process_E_None; - } - - if (*pchr == ':') - pchr++; - } - } - } - - return osl_Process_E_NotFound; -} - } //Anonymous namespace oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, @@ -480,6 +418,38 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( oslFileHandle *pErrorRead ) { + rtl::OUString image; + if (ustrImageName == nullptr) + { + if (nArguments == 0) + { + return osl_Process_E_InvalidError; + } + image = rtl::OUString::unacquired(ustrArguments); + } + else + { + osl::FileBase::RC e = osl::FileBase::getSystemPathFromFileURL( + rtl::OUString::unacquired(&ustrImageName), image); + if (e != osl::FileBase::E_None) + { + SAL_INFO( + "sal.osl", + "getSystemPathFromFileURL(" + << rtl::OUString::unacquired(&ustrImageName) + << ") failed with " << e); + return osl_Process_E_Unknown; + } + } + + if ((Options & osl_Process_SEARCHPATH) != 0) + { + rtl::OUString path; + if (osl::detail::find_in_PATH(image, path)) + { + image = path; + } + } oslProcessError Error; sal_Char* pszWorkDir=0; @@ -488,13 +458,18 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( unsigned int idx; char szImagePath[PATH_MAX] = ""; - char szWorkDir[PATH_MAX] = ""; - - if ( ustrImageName && ustrImageName->length ) + if (!image.isEmpty() + && (UnicodeToText( + szImagePath, SAL_N_ELEMENTS(szImagePath), image.getStr(), + image.getLength()) + == 0)) { - FileURLToPath( szImagePath, PATH_MAX, ustrImageName ); + int e = errno; + SAL_INFO("sal.osl", "UnicodeToText(" << image << ") failed with " << e); + return osl_Process_E_Unknown; } + char szWorkDir[PATH_MAX] = ""; if ( ustrWorkDir != 0 && ustrWorkDir->length ) { FileURLToPath( szWorkDir, PATH_MAX, ustrWorkDir ); @@ -621,20 +596,14 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, ) { int i; - sal_Char path[PATH_MAX + 1]; ProcessData Data; oslThread hThread; - path[0] = '\0'; - memset(&Data,0,sizeof(ProcessData)); Data.m_pInputWrite = pInputWrite; Data.m_pOutputRead = pOutputRead; Data.m_pErrorRead = pErrorRead; - if (pszImageName == NULL) - pszImageName = pszArguments[0]; - OSL_ASSERT(pszImageName != NULL); if ( pszImageName == 0 ) @@ -642,10 +611,6 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, return osl_Process_E_NotFound; } - if ((Options & osl_Process_SEARCHPATH) && - (osl_searchPath_impl(pszImageName, path, sizeof(path)) == osl_Process_E_None)) - pszImageName = path; - Data.m_pszArgs[0] = strdup(pszImageName); Data.m_pszArgs[1] = 0; |