Kaydet (Commit) bb05f112 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove obsolete osl_searchPath_impl

(obsoleting cid#983584)

Change-Id: Icbf25bd364fdabb208abe201ddc146daa60f9b62
üst 7fe2a3fd
...@@ -621,9 +621,7 @@ oslFileError osl_getAbsoluteFileURL(rtl_uString* ustrBaseDirURL, rtl_uString* u ...@@ -621,9 +621,7 @@ oslFileError osl_getAbsoluteFileURL(rtl_uString* ustrBaseDirURL, rtl_uString* u
return oslFileError(rc); return oslFileError(rc);
} }
namespace namespace osl { namespace detail {
{
/********************************************* /*********************************************
No separate error code if unicode to text No separate error code if unicode to text
conversion or getenv fails because for the conversion or getenv fails because for the
...@@ -642,7 +640,10 @@ namespace ...@@ -642,7 +640,10 @@ namespace
return bfound; return bfound;
} }
} }
namespace
{
/********************************************* /*********************************************
No separate error code if unicode to text No separate error code if unicode to text
conversion or getcwd fails because for the conversion or getcwd fails because for the
...@@ -689,7 +690,7 @@ oslFileError osl_searchFileURL(rtl_uString* ustrFilePath, rtl_uString* ustrSearc ...@@ -689,7 +690,7 @@ oslFileError osl_searchFileURL(rtl_uString* ustrFilePath, rtl_uString* ustrSearc
rtl::OUString result; rtl::OUString result;
if (find_in_searchPath(file_path, ustrSearchPath, 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)) find_in_CWD(file_path, result))
{ {
rtl::OUString resolved; rtl::OUString resolved;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "osl/file.h" #include "osl/file.h"
namespace rtl { class OUString; }
oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath); oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath);
oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL); 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 ...@@ -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); 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 #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <osl/conditn.h> #include <osl/conditn.h>
#include <osl/thread.h> #include <osl/thread.h>
#include <osl/file.h> #include <osl/file.h>
#include <osl/file.hxx>
#include <osl/signal.h> #include <osl/signal.h>
#include <rtl/alloc.h> #include <rtl/alloc.h>
#include <sal/log.hxx> #include <sal/log.hxx>
...@@ -94,69 +95,6 @@ struct ProcessData ...@@ -94,69 +95,6 @@ struct ProcessData
static oslProcessImpl* ChildList; static oslProcessImpl* ChildList;
static oslMutex ChildListMutex; 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 } //Anonymous namespace
oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
...@@ -480,6 +418,38 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( ...@@ -480,6 +418,38 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
oslFileHandle *pErrorRead 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; oslProcessError Error;
sal_Char* pszWorkDir=0; sal_Char* pszWorkDir=0;
...@@ -488,13 +458,18 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO( ...@@ -488,13 +458,18 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
unsigned int idx; unsigned int idx;
char szImagePath[PATH_MAX] = ""; char szImagePath[PATH_MAX] = "";
char szWorkDir[PATH_MAX] = ""; if (!image.isEmpty()
&& (UnicodeToText(
if ( ustrImageName && ustrImageName->length ) 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 ) if ( ustrWorkDir != 0 && ustrWorkDir->length )
{ {
FileURLToPath( szWorkDir, PATH_MAX, ustrWorkDir ); FileURLToPath( szWorkDir, PATH_MAX, ustrWorkDir );
...@@ -621,20 +596,14 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, ...@@ -621,20 +596,14 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
) )
{ {
int i; int i;
sal_Char path[PATH_MAX + 1];
ProcessData Data; ProcessData Data;
oslThread hThread; oslThread hThread;
path[0] = '\0';
memset(&Data,0,sizeof(ProcessData)); memset(&Data,0,sizeof(ProcessData));
Data.m_pInputWrite = pInputWrite; Data.m_pInputWrite = pInputWrite;
Data.m_pOutputRead = pOutputRead; Data.m_pOutputRead = pOutputRead;
Data.m_pErrorRead = pErrorRead; Data.m_pErrorRead = pErrorRead;
if (pszImageName == NULL)
pszImageName = pszArguments[0];
OSL_ASSERT(pszImageName != NULL); OSL_ASSERT(pszImageName != NULL);
if ( pszImageName == 0 ) if ( pszImageName == 0 )
...@@ -642,10 +611,6 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, ...@@ -642,10 +611,6 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
return osl_Process_E_NotFound; 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[0] = strdup(pszImageName);
Data.m_pszArgs[1] = 0; Data.m_pszArgs[1] = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment