msi: Avoid using awstring in MsiGetTargetPathW().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-05-17 10:48:17 -05:00 committed by Alexandre Julliard
parent c9fc351021
commit ce3fc1af55
1 changed files with 32 additions and 48 deletions

View File

@ -227,47 +227,6 @@ const WCHAR *msi_get_target_folder( MSIPACKAGE *package, const WCHAR *name )
return folder->ResolvedTarget; return folder->ResolvedTarget;
} }
/***********************************************************************
* MsiGetTargetPath (internal)
*/
static UINT MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
awstring *szPathBuf, LPDWORD pcchPathBuf )
{
MSIPACKAGE *package;
const WCHAR *path;
UINT r = ERROR_FUNCTION_FAILED;
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_GetTargetPath(remote, szFolder, &value);
if (r != ERROR_SUCCESS)
return r;
r = msi_strcpy_to_awstring(value, -1, szPathBuf, pcchPathBuf);
midl_user_free(value);
return r;
}
path = msi_get_target_folder( package, szFolder );
msiobj_release( &package->hdr );
if (!path)
return ERROR_DIRECTORY;
return msi_strcpy_to_awstring( path, -1, szPathBuf, pcchPathBuf );
}
/*********************************************************************** /***********************************************************************
* MsiGetTargetPathA (MSI.@) * MsiGetTargetPathA (MSI.@)
*/ */
@ -321,17 +280,42 @@ UINT WINAPI MsiGetTargetPathA(MSIHANDLE hinst, const char *folder, char *buf, DW
/*********************************************************************** /***********************************************************************
* MsiGetTargetPathW (MSI.@) * MsiGetTargetPathW (MSI.@)
*/ */
UINT WINAPI MsiGetTargetPathW( MSIHANDLE hInstall, LPCWSTR szFolder, UINT WINAPI MsiGetTargetPathW(MSIHANDLE hinst, const WCHAR *folder, WCHAR *buf, DWORD *sz)
LPWSTR szPathBuf, LPDWORD pcchPathBuf )
{ {
awstring path; MSIPACKAGE *package;
const WCHAR *path;
UINT r;
TRACE("%s %p %p\n", debugstr_w(szFolder), szPathBuf, pcchPathBuf); TRACE("%s %p %p\n", debugstr_w(folder), buf, sz);
path.unicode = TRUE; if (!folder)
path.str.w = szPathBuf; return ERROR_INVALID_PARAMETER;
return MSI_GetTargetPath( hInstall, szFolder, &path, pcchPathBuf ); package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
if (!package)
{
WCHAR *path = NULL;
MSIHANDLE remote;
if (!(remote = msi_get_remote(hinst)))
return ERROR_INVALID_HANDLE;
r = remote_GetTargetPath(remote, folder, &path);
if (!r)
r = msi_strncpyW(path, -1, buf, sz);
midl_user_free(path);
return r;
}
path = msi_get_target_folder(package, folder);
if (path)
r = msi_strncpyW(path, -1, buf, sz);
else
r = ERROR_DIRECTORY;
msiobj_release(&package->hdr);
return r;
} }
static WCHAR *get_source_root( MSIPACKAGE *package ) static WCHAR *get_source_root( MSIPACKAGE *package )