https://git.reactos.org/?p=reactos.git;a=commitdiff;h=561fa8d29b562fd692eae0fb25c296d847e887ec

commit 561fa8d29b562fd692eae0fb25c296d847e887ec
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Thu Jul 1 08:42:29 2021 +0900
Commit:     GitHub <[email protected]>
CommitDate: Thu Jul 1 08:42:29 2021 +0900

    [SHELL32] Implement PathResolveA function (#3771)
    
    - Follow-up of #3762.
    - Add PathResolveA implementation by ANSI/Unicode string conversion.
    CORE-12665
---
 dll/win32/shell32/wine/shellpath.c | 44 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/dll/win32/shell32/wine/shellpath.c 
b/dll/win32/shell32/wine/shellpath.c
index b0978280008..7745285af6e 100644
--- a/dll/win32/shell32/wine/shellpath.c
+++ b/dll/win32/shell32/wine/shellpath.c
@@ -631,8 +631,48 @@ VOID WINAPI PathQualifyAW(LPVOID pszPath)
 
 BOOL WINAPI PathResolveA(LPSTR path, LPCSTR *dirs, DWORD flags)
 {
-    FIXME("(%s,%p,0x%08x),stub!\n", debugstr_a(path), dirs, flags);
-    return FALSE;
+    BOOL ret = FALSE;
+    LPWSTR *dirsW = NULL;
+    DWORD iDir, cDirs, cbDirs;
+    WCHAR pathW[MAX_PATH];
+
+    TRACE("PathResolveA(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
+
+    if (dirs)
+    {
+        for (cDirs = 0; dirs[cDirs]; ++cDirs)
+            ;
+
+        cbDirs = (cDirs + 1) * sizeof(LPWSTR);
+        dirsW = SHAlloc(cbDirs);
+        if (!dirsW)
+            goto Cleanup;
+
+        ZeroMemory(dirsW, cbDirs);
+        for (iDir = 0; iDir < cDirs; ++iDir)
+        {
+            __SHCloneStrAtoW(&dirsW[iDir], dirs[iDir]);
+            if (dirsW[iDir] == NULL)
+                goto Cleanup;
+        }
+    }
+
+    SHAnsiToUnicode(path, pathW, _countof(pathW));
+
+    ret = PathResolveW(pathW, (LPCWSTR*)dirsW, flags);
+    if (ret)
+        SHUnicodeToAnsi(pathW, path, MAX_PATH);
+
+Cleanup:
+    if (dirsW)
+    {
+        for (iDir = 0; iDir < cDirs; ++iDir)
+        {
+            SHFree(dirsW[iDir]);
+        }
+        SHFree(dirsW);
+    }
+    return ret;
 }
 
 BOOL WINAPI PathResolveW(LPWSTR path, LPCWSTR *dirs, DWORD flags)

Reply via email to