Add gvdb_table_is_valid() API
authorRyan Lortie <desrt@desrt.ca>
Mon, 19 Jul 2010 00:45:37 +0000 (20:45 -0400)
committerRyan Lortie <desrt@desrt.ca>
Mon, 19 Jul 2010 00:45:37 +0000 (20:45 -0400)
Checks that the on-disk file is still valid.

gvdb-reader.c
gvdb-reader.h

index a043060..01ef756 100644 (file)
@@ -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,
index a29c16e..c960646 100644 (file)
@@ -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,