diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-02 15:43:19 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-06 20:30:32 +0100 |
commit | 552c9ac5a0b78efacbc53426f9a61fac100e87cf (patch) | |
tree | df276c5315cc37ed1c067b008f8a2eea9a30c139 /libmsi/database.c | |
parent | 44397553afaa24fe377c26073473a96e28954902 (diff) | |
download | msitools-552c9ac5a0b78efacbc53426f9a61fac100e87cf.tar.gz msitools-552c9ac5a0b78efacbc53426f9a61fac100e87cf.tar.xz msitools-552c9ac5a0b78efacbc53426f9a61fac100e87cf.zip |
separate the input and output storages for LibmsiDatabase
Diffstat (limited to 'libmsi/database.c')
-rw-r--r-- | libmsi/database.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/libmsi/database.c b/libmsi/database.c index c2f283f..d902756 100644 --- a/libmsi/database.c +++ b/libmsi/database.c @@ -145,7 +145,7 @@ unsigned msi_open_storage( LibmsiDatabase *db, const WCHAR *stname ) goto done; } - hr = IStorage_OpenStorage(db->storage, stname, NULL, + hr = IStorage_OpenStorage(db->infile, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &storage->stg); if (FAILED(hr)) @@ -199,7 +199,7 @@ unsigned msi_create_storage( LibmsiDatabase *db, const WCHAR *stname, IStream *s if (r != LIBMSI_RESULT_SUCCESS) goto done; - hr = IStorage_CreateStorage(db->storage, stname, + hr = IStorage_CreateStorage(db->outfile, stname, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &substg); if (FAILED(hr)) @@ -320,10 +320,10 @@ unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, IStream ** decode_streamname( stname, decoded ); TRACE("%s -> %s\n", debugstr_w(stname), debugstr_w(decoded)); - if (msi_clone_open_stream( db, db->storage, stname, stm ) == LIBMSI_RESULT_SUCCESS) + if (msi_clone_open_stream( db, db->infile, stname, stm ) == LIBMSI_RESULT_SUCCESS) return LIBMSI_RESULT_SUCCESS; - r = IStorage_OpenStream( db->storage, stname, NULL, + r = IStorage_OpenStream( db->infile, stname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, stm ); if( FAILED( r ) ) { @@ -340,7 +340,7 @@ unsigned msi_get_raw_stream( LibmsiDatabase *db, const WCHAR *stname, IStream ** } } } - else stg = db->storage; + else stg = db->infile; if( SUCCEEDED(r) ) { @@ -438,7 +438,8 @@ static VOID _libmsi_database_destroy( LibmsiObject *arg ) free_storages( db ); free_transforms( db ); if (db->strings) msi_destroy_stringtable( db->strings ); - IStorage_Release( db->storage ); + IStorage_Release( db->infile ); + IStorage_Release( db->outfile ); if (db->deletefile) { unlink( db->deletefile ); @@ -598,7 +599,11 @@ LibmsiResult libmsi_database_open(const char *szDBPath, const char *szPersist, L if( TRACE_ON( msi ) ) enum_stream_names( stg ); - db->storage = stg; + db->infile = stg; + IStorage_AddRef( db->infile ); + db->outfile = stg; + IStorage_AddRef( db->outfile ); + db->mode = szMode; if (created) db->deletefile = strdup( szDBPath ); @@ -607,14 +612,13 @@ LibmsiResult libmsi_database_open(const char *szDBPath, const char *szPersist, L list_init( &db->streams ); list_init( &db->storages ); - db->strings = msi_load_string_table( stg, &db->bytes_per_strref ); + db->strings = msi_load_string_table( db->infile, &db->bytes_per_strref ); if( !db->strings ) goto end; ret = LIBMSI_RESULT_SUCCESS; msiobj_addref( &db->hdr ); - IStorage_AddRef( stg ); *pdb = db; end: |