Commit 018bc9a0 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Test and fix the size of stream fields in a record.

parent d757bfee
...@@ -410,6 +410,17 @@ UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, unsigned int iField, ...@@ -410,6 +410,17 @@ UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, unsigned int iField,
return ret; return ret;
} }
static UINT msi_get_stream_size( IStream *stm )
{
STATSTG stat;
HRESULT r;
r = IStream_Stat( stm, &stat, STATFLAG_NONAME );
if( FAILED(r) )
return 0;
return stat.cbSize.QuadPart;
}
UINT MSI_RecordDataSize(MSIRECORD *rec, unsigned int iField) UINT MSI_RecordDataSize(MSIRECORD *rec, unsigned int iField)
{ {
TRACE("%p %d\n", rec, iField); TRACE("%p %d\n", rec, iField);
...@@ -425,6 +436,8 @@ UINT MSI_RecordDataSize(MSIRECORD *rec, unsigned int iField) ...@@ -425,6 +436,8 @@ UINT MSI_RecordDataSize(MSIRECORD *rec, unsigned int iField)
return lstrlenW( rec->fields[iField].u.szwVal ); return lstrlenW( rec->fields[iField].u.szwVal );
case MSIFIELD_NULL: case MSIFIELD_NULL:
break; break;
case MSIFIELD_STREAM:
return msi_get_stream_size( rec->fields[iField].u.stream );
} }
return 0; return 0;
} }
......
...@@ -220,6 +220,10 @@ void test_msirecord(void) ...@@ -220,6 +220,10 @@ void test_msirecord(void)
r = MsiRecordReadStream(h, 0, buf, &sz); r = MsiRecordReadStream(h, 0, buf, &sz);
ok(r == ERROR_INVALID_DATATYPE, "read non-stream type\n"); ok(r == ERROR_INVALID_DATATYPE, "read non-stream type\n");
ok(sz == sizeof buf, "set sz\n"); ok(sz == sizeof buf, "set sz\n");
r = MsiRecordDataSize( h, -1);
ok(r == 0,"MsiRecordDataSize returned wrong size\n");
r = MsiRecordDataSize( h, 0);
ok(r == 4,"MsiRecordDataSize returned wrong size\n");
/* same record, now close it */ /* same record, now close it */
r = MsiCloseHandle(h); r = MsiCloseHandle(h);
...@@ -279,6 +283,8 @@ void test_msirecord(void) ...@@ -279,6 +283,8 @@ void test_msirecord(void)
r = MsiRecordReadStream(h, 1, NULL, &sz); r = MsiRecordReadStream(h, 1, NULL, &sz);
ok(r == ERROR_SUCCESS, "bytes left wrong after reset\n"); ok(r == ERROR_SUCCESS, "bytes left wrong after reset\n");
ok(sz==26,"couldn't get size of stream\n"); ok(sz==26,"couldn't get size of stream\n");
r = MsiRecordDataSize(h,1);
ok(r == 26,"MsiRecordDataSize returned wrong size\n");
/* now close the stream record */ /* now close the stream record */
r = MsiCloseHandle(h); r = MsiCloseHandle(h);
......
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