From: Zebediah Figura zfigura@codeweavers.com
--- dlls/msi/msi.c | 4 ++-- dlls/msi/msipriv.h | 7 +++++++ dlls/msi/tests/package.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 2b821d08cf5..611399a8fb0 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -2037,14 +2037,14 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, const WCHAR *component, DW } else if ((file = msi_get_loaded_file( package, comp->KeyPath ))) { - *cost = max( 8, comp->Cost / 512 ); + *cost = cost_from_size( comp->Cost ); *buflen = set_drive( drive, file->TargetPath[0] ); r = ERROR_SUCCESS; } } else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK) { - *temp = max( 8, stat.cbSize.QuadPart / 512 ); + *temp = cost_from_size( stat.cbSize.QuadPart ); *buflen = set_drive( drive, path[0] ); r = ERROR_SUCCESS; } diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 4c2f2ae2589..588aa9a7487 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -1194,4 +1194,11 @@ static inline LPWSTR strdupUtoW( LPCSTR str ) return ret; }
+static inline int cost_from_size( int size ) +{ + /* Cost is size rounded up to the nearest 4096 bytes, + * expressed in units of 512 bytes. */ + return ((size + 4095) & ~4095) / 512; +} + #endif /* __WINE_MSI_PRIVATE__ */ diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 9f15bc37520..9257a835891 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -8628,7 +8628,7 @@ static void test_costs(void) ok( len == 2, "expected len == 2, got %lu\n", len ); ok( drive[0], "expected a drive\n" ); ok( !cost, "expected cost == 0, got %d\n", cost ); - ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp ); + todo_wine ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
/* increased index */ len = sizeof(drive);