Gijs Vermeulen : shell32: Implement PathResolve.

Alexandre Julliard julliard at winehq.org
Mon Apr 20 15:01:53 CDT 2020


Module: wine
Branch: oldstable
Commit: 2d6f58159576073ea58045d2e3c39a6f71285d5e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2d6f58159576073ea58045d2e3c39a6f71285d5e

Author: Gijs Vermeulen <gijsvrm at codeweavers.com>
Date:   Wed Dec 11 11:16:17 2019 +0100

shell32: Implement PathResolve.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48082
Signed-off-by: Gijs Vermeulen <gijsvrm at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit a5a2749cfe5fe6c73fa344ddc2f564bd6cb85356)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/shell32/shellpath.c | 69 +++++++++++++++++++++++++++++++++++++++++-------
 include/shlobj.h         |  3 +--
 2 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index f08474b363..8dcdcd0dff 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -684,27 +684,78 @@ BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
 	return PathQualifyA(pszPath);
 }
 
-static BOOL PathResolveA(LPSTR path, LPCSTR *paths, DWORD flags)
+BOOL WINAPI PathFindOnPathExA(LPSTR,LPCSTR *,DWORD);
+BOOL WINAPI PathFindOnPathExW(LPWSTR,LPCWSTR *,DWORD);
+BOOL WINAPI PathFileExistsDefExtA(LPSTR,DWORD);
+BOOL WINAPI PathFileExistsDefExtW(LPWSTR,DWORD);
+
+static BOOL PathResolveA(char *path, const char **dirs, DWORD flags)
 {
-    FIXME("(%s,%p,0x%08x),stub!\n", debugstr_a(path), paths, flags);
-    return FALSE;
+    BOOL is_file_spec = PathIsFileSpecA(path);
+    DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xff;
+
+    TRACE("(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
+
+    if (flags & PRF_VERIFYEXISTS && !PathFileExistsA(path))
+    {
+        if (PathFindOnPathExA(path, dirs, dwWhich))
+            return TRUE;
+        if (PathFileExistsDefExtA(path, dwWhich))
+            return TRUE;
+        if (!is_file_spec) GetFullPathNameA(path, MAX_PATH, path, NULL);
+        SetLastError(ERROR_FILE_NOT_FOUND);
+        return FALSE;
+    }
+
+    if (is_file_spec)
+    {
+        SetLastError(ERROR_FILE_NOT_FOUND);
+        return FALSE;
+    }
+
+    GetFullPathNameA(path, MAX_PATH, path, NULL);
+
+    return TRUE;
 }
 
-static BOOL PathResolveW(LPWSTR path, LPCWSTR *paths, DWORD flags)
+static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags)
 {
-    FIXME("(%s,%p,0x%08x),stub!\n", debugstr_w(path), paths, flags);
-    return FALSE;
+    BOOL is_file_spec = PathIsFileSpecW(path);
+    DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xff;
+
+    TRACE("(%s,%p,0x%08x)\n", debugstr_w(path), dirs, flags);
+
+    if (flags & PRF_VERIFYEXISTS && !PathFileExistsW(path))
+    {
+        if (PathFindOnPathExW(path, dirs, dwWhich))
+            return TRUE;
+        if (PathFileExistsDefExtW(path, dwWhich))
+            return TRUE;
+        if (!is_file_spec) GetFullPathNameW(path, MAX_PATH, path, NULL);
+        SetLastError(ERROR_FILE_NOT_FOUND);
+        return FALSE;
+    }
+
+    if (is_file_spec)
+    {
+        SetLastError(ERROR_FILE_NOT_FOUND);
+        return FALSE;
+    }
+
+    GetFullPathNameW(path, MAX_PATH, path, NULL);
+
+    return TRUE;
 }
 
 /*************************************************************************
  * PathResolve [SHELL32.51]
  */
-BOOL WINAPI PathResolveAW(LPVOID path, LPCVOID *paths, DWORD flags)
+BOOL WINAPI PathResolveAW(void *path, const void **paths, DWORD flags)
 {
     if (SHELL_OsIsUnicode())
-        return PathResolveW(path, (LPCWSTR*)paths, flags);
+        return PathResolveW(path, (const WCHAR **)paths, flags);
     else
-        return PathResolveA(path, (LPCSTR*)paths, flags);
+        return PathResolveA(path, (const char **)paths, flags);
 }
 
 /*************************************************************************
diff --git a/include/shlobj.h b/include/shlobj.h
index e963578d6c..f61dfa7d66 100644
--- a/include/shlobj.h
+++ b/include/shlobj.h
@@ -1717,10 +1717,9 @@ BOOL WINAPI WriteCabinetState(CABINETSTATE *);
 
 /* PathResolve flags */
 #define PRF_VERIFYEXISTS         0x01
-#define PRF_EXECUTABLE           0x02
 #define PRF_TRYPROGRAMEXTENSIONS 0x03
 #define PRF_FIRSTDIRDEF          0x04
-#define PRF_DONTFINDLINK         0x08
+#define PRF_DONTFINDLNK          0x08
 #define PRF_REQUIREABSOLUTE      0x10
 
 VOID WINAPI PathGetShortPath(LPWSTR pszPath);




More information about the wine-cvs mailing list