mirror of
https://github.com/reactos/reactos.git
synced 2025-03-01 03:45:16 +00:00
[SHELL32] SHELL_FindExecutable: improve path handling code (#7633)
Follow-up of42d5dfd3de
. - Revert "shell32: Fix ShellExecute for non-filespec paths."0bad544aab
. - Apply "shell32: Look for the file name without extension also for the path search case."38b6640be9
. - Clear leading/trailing whitespaces (an improvement by Doug Lyons). - Update the comment for xlpFile buffer definition, to match the current code behaviour. This fixes some failures for the following tests: - shell32_apitest:ShellExecCmdLine: 12 failures less, - shell32_apitest:ShellExecuteEx: 5 failures less, - shell32_winetest:shlexec: crash fixed, now 13 failures as before, - wshom_winetest:wshom: crash fixed, now 2 failures less too (0 failures). I've also tested: the problem which was intended to be fixed by the guilty commit (CORE-19953) still remains fixed after this change. CORE-19964
This commit is contained in:
parent
fe7a58d92e
commit
c7d1aa3e92
1 changed files with 20 additions and 46 deletions
|
@ -748,7 +748,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
|
||||||
WCHAR wBuffer[256]; /* Used to GetProfileString */
|
WCHAR wBuffer[256]; /* Used to GetProfileString */
|
||||||
UINT retval = SE_ERR_NOASSOC;
|
UINT retval = SE_ERR_NOASSOC;
|
||||||
WCHAR *tok; /* token pointer */
|
WCHAR *tok; /* token pointer */
|
||||||
WCHAR xlpFile[MAX_PATH]; /* result of SearchPath */
|
WCHAR xlpFile[MAX_PATH]; /* result of PathResolve */
|
||||||
DWORD attribs; /* file attributes */
|
DWORD attribs; /* file attributes */
|
||||||
WCHAR curdir[MAX_PATH];
|
WCHAR curdir[MAX_PATH];
|
||||||
const WCHAR *search_paths[3] = {0};
|
const WCHAR *search_paths[3] = {0};
|
||||||
|
@ -777,54 +777,28 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCurrentDirectoryW(ARRAY_SIZE(curdir), curdir);
|
GetCurrentDirectoryW(ARRAY_SIZE(curdir), curdir);
|
||||||
if (!PathIsFileSpecW(lpFile))
|
|
||||||
{
|
|
||||||
BOOL found = FALSE;
|
|
||||||
if (lpPath && *lpPath)
|
|
||||||
{
|
|
||||||
TRACE("lpPath %s\n", debugstr_w(lpPath));
|
|
||||||
PathCombineW(xlpFile, lpPath, lpFile);
|
|
||||||
if (PathFileExistsDefExtW(xlpFile, WHICH_DEFAULT | WHICH_OPTIONAL) || PathFileExistsW(xlpFile))
|
|
||||||
{
|
|
||||||
GetFullPathNameW(xlpFile, ARRAY_SIZE(xlpFile), xlpFile, NULL);
|
|
||||||
found = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
lstrcpyW(xlpFile, lpFile);
|
|
||||||
if (PathFileExistsDefExtW(xlpFile, WHICH_DEFAULT | WHICH_OPTIONAL) || PathFileExistsW(xlpFile))
|
|
||||||
{
|
|
||||||
GetFullPathNameW(xlpFile, ARRAY_SIZE(xlpFile), xlpFile, NULL);
|
|
||||||
found = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found)
|
|
||||||
{
|
|
||||||
lpFile = xlpFile;
|
|
||||||
lstrcpyW(lpResult, xlpFile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
xlpFile[0] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (lpPath && *lpPath)
|
if (lpPath && *lpPath)
|
||||||
{
|
{
|
||||||
search_paths[0] = lpPath;
|
search_paths[0] = lpPath;
|
||||||
search_paths[1] = curdir;
|
search_paths[1] = curdir;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
search_paths[0] = curdir;
|
search_paths[0] = curdir;
|
||||||
|
}
|
||||||
|
|
||||||
lstrcpyW(xlpFile, lpFile);
|
lstrcpyW(xlpFile, lpFile);
|
||||||
if (PathResolveW(xlpFile, search_paths, PRF_TRYPROGRAMEXTENSIONS | PRF_VERIFYEXISTS))
|
if (PathResolveW(xlpFile, search_paths, PRF_TRYPROGRAMEXTENSIONS | PRF_VERIFYEXISTS) ||
|
||||||
|
PathFindOnPathW(xlpFile, search_paths))
|
||||||
{
|
{
|
||||||
TRACE("PathResolveW returned non-zero\n");
|
TRACE("PathResolveW returned non-zero\n");
|
||||||
lpFile = xlpFile;
|
lpFile = xlpFile;
|
||||||
|
PathRemoveBlanksW(xlpFile);
|
||||||
lstrcpyW(lpResult, xlpFile);
|
lstrcpyW(lpResult, xlpFile);
|
||||||
/* The file was found in lpPath or one of the directories in the system-wide search path */
|
/* The file was found in lpPath or one of the directories in the system-wide search path */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
xlpFile[0] = '\0';
|
xlpFile[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue