Commit 4a1c243e authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Factor out common code from MsiEnumComponentCostsW.

parent 0858dee3
...@@ -1825,6 +1825,14 @@ UINT WINAPI MsiEnumComponentCostsA( MSIHANDLE handle, LPCSTR component, DWORD in ...@@ -1825,6 +1825,14 @@ UINT WINAPI MsiEnumComponentCostsA( MSIHANDLE handle, LPCSTR component, DWORD in
return r; return r;
} }
static UINT set_drive( WCHAR *buffer, WCHAR letter )
{
buffer[0] = letter;
buffer[1] = ':';
buffer[2] = 0;
return 2;
}
UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD index, UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD index,
INSTALLSTATE state, LPWSTR drive, DWORD *buflen, INSTALLSTATE state, LPWSTR drive, DWORD *buflen,
int *cost, int *temp ) int *cost, int *temp )
...@@ -1896,29 +1904,20 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i ...@@ -1896,29 +1904,20 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i
if (!comp->Enabled || !comp->KeyPath) if (!comp->Enabled || !comp->KeyPath)
{ {
*cost = 0; *cost = 0;
drive[0] = path[0]; *buflen = set_drive( drive, path[0] );
drive[1] = ':';
drive[2] = 0;
*buflen = 2;
r = ERROR_SUCCESS; r = ERROR_SUCCESS;
} }
else if ((file = msi_get_loaded_file( package, comp->KeyPath ))) else if ((file = msi_get_loaded_file( package, comp->KeyPath )))
{ {
*cost = max( 8, comp->Cost / 512 ); *cost = max( 8, comp->Cost / 512 );
drive[0] = file->TargetPath[0]; *buflen = set_drive( drive, file->TargetPath[0] );
drive[1] = ':';
drive[2] = 0;
*buflen = 2;
r = ERROR_SUCCESS; r = ERROR_SUCCESS;
} }
} }
else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK) else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK)
{ {
*temp = max( 8, stat.cbSize.QuadPart / 512 ); *temp = max( 8, stat.cbSize.QuadPart / 512 );
drive[0] = path[0]; *buflen = set_drive( drive, path[0] );
drive[1] = ':';
drive[2] = 0;
*buflen = 2;
r = ERROR_SUCCESS; r = ERROR_SUCCESS;
} }
msiobj_release( &package->hdr ); msiobj_release( &package->hdr );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment