mirror of
https://github.com/reactos/reactos.git
synced 2025-05-19 17:14:32 +00:00
Use default PATHEXT if none found in environment
svn path=/trunk/; revision=10082
This commit is contained in:
parent
c8d9ece95d
commit
093e925a66
1 changed files with 13 additions and 8 deletions
|
@ -96,14 +96,14 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
LPTSTR pszBuffer = NULL;
|
LPTSTR pszBuffer = NULL;
|
||||||
DWORD dwBuffer, len;
|
DWORD dwBuffer, len;
|
||||||
LPTSTR s,f;
|
LPTSTR s,f;
|
||||||
// initialize full name buffer
|
/* initialize full name buffer */
|
||||||
*pFullName = _T('\0');
|
*pFullName = _T('\0');
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("SearchForExecutableSingle: \'%s\' with ext: \'%s\'\n"), pFileName, pExtension);
|
DebugPrintf (_T("SearchForExecutableSingle: \'%s\' with ext: \'%s\'\n"), pFileName, pExtension);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check if valid directly on specified path
|
/* Check if valid directly on specified path */
|
||||||
if (_tcschr (pFileName, _T('\\')) != NULL)
|
if (_tcschr (pFileName, _T('\\')) != NULL)
|
||||||
{
|
{
|
||||||
LPTSTR pFilePart;
|
LPTSTR pFilePart;
|
||||||
|
@ -119,7 +119,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
|
|
||||||
if(pFilePart == 0)
|
if(pFilePart == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
// Add extension and test file:
|
/* Add extension and test file: */
|
||||||
if (pExtension)
|
if (pExtension)
|
||||||
_tcscat(szPathBuffer, pExtension);
|
_tcscat(szPathBuffer, pExtension);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search in current directory
|
/* search in current directory */
|
||||||
len = GetCurrentDirectory (MAX_PATH, szPathBuffer);
|
len = GetCurrentDirectory (MAX_PATH, szPathBuffer);
|
||||||
if (szPathBuffer[len - 1] != _T('\\'))
|
if (szPathBuffer[len - 1] != _T('\\'))
|
||||||
{
|
{
|
||||||
|
@ -157,7 +157,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// load environment varable PATH into buffer
|
/* load environment varable PATH into buffer */
|
||||||
pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
||||||
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
|
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
|
||||||
if (dwBuffer > ENV_BUFFER_SIZE)
|
if (dwBuffer > ENV_BUFFER_SIZE)
|
||||||
|
@ -167,7 +167,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// search in PATH
|
/* search in PATH */
|
||||||
s = pszBuffer;
|
s = pszBuffer;
|
||||||
while (s && *s)
|
while (s && *s)
|
||||||
{
|
{
|
||||||
|
@ -214,19 +214,20 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pExtensio
|
||||||
BOOL
|
BOOL
|
||||||
SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
|
SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
|
||||||
{
|
{
|
||||||
|
static TCHAR pszDefaultPathExt[] = _T(".COM;.EXE;.BAT;.CMD");
|
||||||
LPTSTR pszBuffer = NULL;
|
LPTSTR pszBuffer = NULL;
|
||||||
LPTSTR pCh;
|
LPTSTR pCh;
|
||||||
DWORD dwBuffer;
|
DWORD dwBuffer;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("SearchForExecutable: \'%s\'\n"), pFileName);
|
DebugPrintf (_T("SearchForExecutable: \'%s\'\n"), pFileName);
|
||||||
#endif
|
#endif
|
||||||
// check the filename directly
|
/* check the filename directly */
|
||||||
if (SearchForExecutableSingle(pFileName, pFullName, NULL))
|
if (SearchForExecutableSingle(pFileName, pFullName, NULL))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load environment varable PATHEXT
|
/* load environment varable PATHEXT */
|
||||||
pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
|
||||||
dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, ENV_BUFFER_SIZE);
|
dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, ENV_BUFFER_SIZE);
|
||||||
if (dwBuffer > ENV_BUFFER_SIZE)
|
if (dwBuffer > ENV_BUFFER_SIZE)
|
||||||
|
@ -234,6 +235,10 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
|
||||||
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer * sizeof (TCHAR));
|
GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer * sizeof (TCHAR));
|
||||||
}
|
}
|
||||||
|
else if (0 == dwBuffer)
|
||||||
|
{
|
||||||
|
_tcscpy(pszBuffer, pszDefaultPathExt);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf (_T("SearchForExecutable(): Loaded PATHEXT: %s\n"), pszBuffer);
|
DebugPrintf (_T("SearchForExecutable(): Loaded PATHEXT: %s\n"), pszBuffer);
|
||||||
|
|
Loading…
Reference in a new issue