Zebediah Figura : msi: Avoid using awstring in MsiGetSourcePathW().

Alexandre Julliard julliard at winehq.org
Thu May 17 19:10:59 CDT 2018


Module: wine
Branch: master
Commit: 48aeef69fc99ff1460da934f4933f0499ff33b13
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=48aeef69fc99ff1460da934f4933f0499ff33b13

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Thu May 17 10:48:19 2018 -0500

msi: Avoid using awstring in MsiGetSourcePathW().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msi/install.c | 91 +++++++++++++++++++-----------------------------------
 1 file changed, 32 insertions(+), 59 deletions(-)

diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index d62fe26..e043c04 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -367,58 +367,6 @@ WCHAR *msi_resolve_source_folder( MSIPACKAGE *package, const WCHAR *name, MSIFOL
 }
 
 /***********************************************************************
- * MSI_GetSourcePath   (internal)
- */
-static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
-                               awstring *szPathBuf, LPDWORD pcchPathBuf )
-{
-    MSIPACKAGE *package;
-    LPWSTR path;
-    UINT r = ERROR_FUNCTION_FAILED;
-
-    TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
-
-    if (!szFolder)
-        return ERROR_INVALID_PARAMETER;
-
-    package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
-    if (!package)
-    {
-        LPWSTR value = NULL;
-        MSIHANDLE remote;
-
-        if (!(remote = msi_get_remote(hInstall)))
-            return ERROR_INVALID_HANDLE;
-
-        r = remote_GetSourcePath(remote, szFolder, &value);
-        if (r != ERROR_SUCCESS)
-            return r;
-
-        r = msi_strcpy_to_awstring(value, -1, szPathBuf, pcchPathBuf);
-
-        midl_user_free(value);
-        return r;
-    }
-
-    if (szPathBuf->str.w && !pcchPathBuf )
-    {
-        msiobj_release( &package->hdr );
-        return ERROR_INVALID_PARAMETER;
-    }
-
-    path = msi_resolve_source_folder( package, szFolder, NULL );
-    msiobj_release( &package->hdr );
-
-    TRACE("path = %s\n", debugstr_w(path));
-    if (!path)
-        return ERROR_DIRECTORY;
-
-    r = msi_strcpy_to_awstring( path, -1, szPathBuf, pcchPathBuf );
-    msi_free( path );
-    return r;
-}
-
-/***********************************************************************
  * MsiGetSourcePathA     (MSI.@)
  */
 UINT WINAPI MsiGetSourcePathA(MSIHANDLE hinst, const char *folder, char *buf, DWORD *sz)
@@ -471,17 +419,42 @@ UINT WINAPI MsiGetSourcePathA(MSIHANDLE hinst, const char *folder, char *buf, DW
 /***********************************************************************
  * MsiGetSourcePathW     (MSI.@)
  */
-UINT WINAPI MsiGetSourcePathW( MSIHANDLE hInstall, LPCWSTR szFolder,
-                               LPWSTR szPathBuf, LPDWORD pcchPathBuf )
+UINT WINAPI MsiGetSourcePathW(MSIHANDLE hinst, const WCHAR *folder, WCHAR *buf, DWORD *sz)
 {
-    awstring str;
+    MSIPACKAGE *package;
+    const WCHAR *path;
+    UINT r;
+
+    TRACE("%s %p %p\n", debugstr_w(folder), buf, sz);
+
+    if (!folder)
+        return ERROR_INVALID_PARAMETER;
+
+    package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
+    if (!package)
+    {
+        WCHAR *path = NULL;
+        MSIHANDLE remote;
 
-    TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf );
+        if (!(remote = msi_get_remote(hinst)))
+            return ERROR_INVALID_HANDLE;
+
+        r = remote_GetSourcePath(remote, folder, &path);
+        if (!r)
+            r = msi_strncpyW(path, -1, buf, sz);
 
-    str.unicode = TRUE;
-    str.str.w = szPathBuf;
+        midl_user_free(path);
+        return r;
+    }
 
-    return MSI_GetSourcePath( hInstall, szFolder, &str, pcchPathBuf );
+    path = msi_resolve_source_folder(package, folder, NULL);
+    if (path)
+        r = msi_strncpyW(path, -1, buf, sz);
+    else
+        r = ERROR_DIRECTORY;
+
+    msiobj_release(&package->hdr);
+    return r;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list