From 6f89276d0065a3476f9072ae5ec116633f56bdc1 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Mon, 17 Dec 2012 14:28:02 +0100 Subject: database: make commit() GObject-like --- libmsi/libmsi-database.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'libmsi') diff --git a/libmsi/libmsi-database.c b/libmsi/libmsi-database.c index 470dacc..0720cc3 100644 --- a/libmsi/libmsi-database.c +++ b/libmsi/libmsi-database.c @@ -2291,15 +2291,15 @@ end: return ret; } -LibmsiResult libmsi_database_commit( LibmsiDatabase *db ) +gboolean +libmsi_database_commit (LibmsiDatabase *db, GError **error) { unsigned r = LIBMSI_RESULT_SUCCESS; unsigned bytes_per_strref; - TRACE("%d\n", db); + TRACE ("%p\n", db); - if( !db ) - return LIBMSI_RESULT_INVALID_HANDLE; + g_return_val_if_fail (LIBMSI_IS_DATABASE (db), FALSE); g_object_ref(db); if (db->mode == LIBMSI_DB_OPEN_READONLY) @@ -2307,31 +2307,31 @@ LibmsiResult libmsi_database_commit( LibmsiDatabase *db ) /* FIXME: lock the database */ - r = msi_save_string_table( db->strings, db, &bytes_per_strref ); - if( r != LIBMSI_RESULT_SUCCESS ) - { - WARN("failed to save string table r=%08x\n",r); + r = msi_save_string_table (db->strings, db, &bytes_per_strref); + if (r != LIBMSI_RESULT_SUCCESS) { + g_set_error (error, LIBMSI_RESULT_ERROR, r, + "failed to save string table r=%08x\n", r); goto end; } - r = msi_enum_db_storages( db, commit_storage, db ); - if (r != LIBMSI_RESULT_SUCCESS) - { - WARN("failed to save storages r=%08x\n",r); + r = msi_enum_db_storages (db, commit_storage, db); + if (r != LIBMSI_RESULT_SUCCESS) { + g_set_error (error, LIBMSI_RESULT_ERROR, r, + "failed to save storages r=%08x\n", r); goto end; } - r = msi_enum_db_streams( db, commit_stream, db ); - if (r != LIBMSI_RESULT_SUCCESS) - { - WARN("failed to save streams r=%08x\n",r); + r = msi_enum_db_streams (db, commit_stream, db); + if (r != LIBMSI_RESULT_SUCCESS) { + g_set_error (error, LIBMSI_RESULT_ERROR, r, + "failed to save streams r=%08x\n", r); goto end; } - r = _libmsi_database_commit_tables( db, bytes_per_strref ); - if (r != LIBMSI_RESULT_SUCCESS) - { - WARN("failed to save tables r=%08x\n",r); + r = _libmsi_database_commit_tables (db, bytes_per_strref); + if (r != LIBMSI_RESULT_SUCCESS) { + g_set_error (error, LIBMSI_RESULT_ERROR, r, + "failed to save tables r=%08x\n", r); goto end; } @@ -2347,7 +2347,7 @@ LibmsiResult libmsi_database_commit( LibmsiDatabase *db ) end: g_object_unref(db); - return r; + return r == LIBMSI_RESULT_SUCCESS; } struct msi_primary_key_record_info -- cgit