Commit 5426e597 authored by Yuxuan Shui's avatar Yuxuan Shui Committed by Alexandre Julliard

shell32: Make sure PathResolve can find files in the current directory.

Previously looking for file that does exist in current directory will fail because of the early `!PathFileExists(path)` check, even when the current directory is specified in `dirs`.
parent 520b7c6d
......@@ -691,7 +691,7 @@ static BOOL PathResolveA(char *path, const char **dirs, DWORD flags)
TRACE("(%s,%p,0x%08lx)\n", debugstr_a(path), dirs, flags);
if (flags & PRF_VERIFYEXISTS && !PathFileExistsA(path))
if (flags & PRF_VERIFYEXISTS)
{
if (PathFindOnPathExA(path, dirs, dwWhich))
return TRUE;
......@@ -720,7 +720,7 @@ static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags)
TRACE("(%s,%p,0x%08lx)\n", debugstr_w(path), dirs, flags);
if (flags & PRF_VERIFYEXISTS && !PathFileExistsW(path))
if (flags & PRF_VERIFYEXISTS)
{
if (PathFindOnPathExW(path, dirs, dwWhich))
return TRUE;
......
......@@ -3048,10 +3048,14 @@ static void test_PathResolve(void)
ok(!lstrcmpiW(path, L"C:\\windows\\regedit.exe") || !lstrcmpiW(path, L"C:\\windows\\system32\\regedit.exe"),
"unexpected path %s\n", wine_dbgstr_w(path));
/* show that PathResolve doesn't check current directory */
if (argv0_basep)
{
WCHAR *ext;
const WCHAR *search_path[] = {
argv0_dir,
NULL
};
/* show that PathResolve doesn't check current directory */
lstrcpyW(argv0_base, argv0_basep);
GetCurrentDirectoryW(MAX_PATH, curdir);
SetCurrentDirectoryW(argv0_dir);
......@@ -3065,6 +3069,16 @@ static void test_PathResolve(void)
ret = pPathResolve(argv0_base, NULL, PRF_VERIFYEXISTS | PRF_TRYPROGRAMEXTENSIONS);
ok(!ret, "resolving argv0 without extension succeeded unexpectedly, result: %s\n", wine_dbgstr_w(argv0_base));
}
/* show that PathResolve will check specified search path, even if it's the current directory */
lstrcpyW(argv0_base, argv0_basep);
if ((ext = wcsrchr(argv0_base, '.')))
{
*ext = 0;
ret = pPathResolve(argv0_base, search_path, PRF_VERIFYEXISTS | PRF_TRYPROGRAMEXTENSIONS);
ok(ret, "resolving argv0 without extension with search path failed unexpectedly, result: %s\n", wine_dbgstr_w(argv0_base));
}
SetCurrentDirectoryW(curdir);
}
else
......
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