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

This commit is contained in:
Mike McCormack 2005-05-27 09:26:13 +00:00 committed by Alexandre Julliard
parent d757bfeeaf
commit 018bc9a0cd
2 changed files with 19 additions and 0 deletions

View File

@ -410,6 +410,17 @@ UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, unsigned int iField,
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)
{
TRACE("%p %d\n", rec, iField);
@ -425,6 +436,8 @@ UINT MSI_RecordDataSize(MSIRECORD *rec, unsigned int iField)
return lstrlenW( rec->fields[iField].u.szwVal );
case MSIFIELD_NULL:
break;
case MSIFIELD_STREAM:
return msi_get_stream_size( rec->fields[iField].u.stream );
}
return 0;
}

View File

@ -220,6 +220,10 @@ void test_msirecord(void)
r = MsiRecordReadStream(h, 0, buf, &sz);
ok(r == ERROR_INVALID_DATATYPE, "read non-stream type\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 */
r = MsiCloseHandle(h);
@ -279,6 +283,8 @@ void test_msirecord(void)
r = MsiRecordReadStream(h, 1, NULL, &sz);
ok(r == ERROR_SUCCESS, "bytes left wrong after reset\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 */
r = MsiCloseHandle(h);