1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

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`.
This commit is contained in:
Yuxuan Shui 2024-03-18 16:52:45 +00:00 committed by Alexandre Julliard
parent 520b7c6d83
commit 5426e597bb
2 changed files with 17 additions and 3 deletions

View file

@ -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;

View file

@ -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