From df40747190a0fff4582c84b101f74e5da91f8f72 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Sun, 18 Jul 2010 20:45:37 -0400 Subject: [PATCH] Add gvdb_table_is_valid() API Checks that the on-disk file is still valid. --- gvdb-reader.c | 17 +++++++++++++++++ gvdb-reader.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/gvdb-reader.c b/gvdb-reader.c index a04306056..01ef75649 100644 --- a/gvdb-reader.c +++ b/gvdb-reader.c @@ -534,6 +534,23 @@ gvdb_table_unref (GvdbTable *file) } } +/** + * gvdb_table_is_valid: + * @table: a #GvdbTable + * @returns: %TRUE if @table is still valid + * + * Checks if the table is still valid. + * + * An on-disk GVDB can be marked as invalid. This happens when the file + * has been replaced. The appropriate action is typically to reopen the + * file. + **/ +gboolean +gvdb_table_is_valid (GvdbTable *table) +{ + return !!table->data; +} + void gvdb_table_walk (GvdbTable *table, const gchar *key, diff --git a/gvdb-reader.h b/gvdb-reader.h index a29c16e1c..c96064627 100644 --- a/gvdb-reader.h +++ b/gvdb-reader.h @@ -49,6 +49,9 @@ G_GNUC_INTERNAL gboolean gvdb_table_has_value (GvdbTable *table, const gchar *key); +G_GNUC_INTERNAL +gboolean gvdb_table_is_valid (GvdbTable *table); + typedef void (*GvdbWalkValueFunc) (const gchar *name, gsize name_len, GVariant *value,