[tracker] libtracker-miner: Add tracker_file_system_steal_property()



commit 7972ba5961f22b15f1b9eaacc383201354ed8502
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 2 23:58:40 2016 +0200

    libtracker-miner: Add tracker_file_system_steal_property()
    
    This call retrieves and removes data stored in the TrackerFileSystem,
    the caller must free the retrieved data.

 src/libtracker-miner/tracker-file-system.c |   41 ++++++++++++++++++++++++++++
 src/libtracker-miner/tracker-file-system.h |    3 ++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-system.c b/src/libtracker-miner/tracker-file-system.c
index 8a0e691..5573e1e 100644
--- a/src/libtracker-miner/tracker-file-system.c
+++ b/src/libtracker-miner/tracker-file-system.c
@@ -933,6 +933,47 @@ tracker_file_system_unset_property (TrackerFileSystem *file_system,
        g_array_remove_index (data->properties, index);
 }
 
+gpointer
+tracker_file_system_steal_property (TrackerFileSystem *file_system,
+                                    GFile             *file,
+                                    GQuark             prop)
+{
+       FileNodeData *data;
+       FileNodeProperty property, *match;
+       GNode *node;
+       guint index;
+       gpointer prop_value;
+
+       g_return_val_if_fail (TRACKER_IS_FILE_SYSTEM (file_system), NULL);
+       g_return_val_if_fail (file != NULL, NULL);
+       g_return_val_if_fail (prop > 0, NULL);
+
+       node = file_system_get_node (file_system, file);
+       g_return_val_if_fail (node != NULL, NULL);
+
+       data = node->data;
+       property.prop_quark = prop;
+
+       match = bsearch (&property, data->properties->data,
+                        data->properties->len, sizeof (FileNodeProperty),
+                        search_property_node);
+
+       if (!match) {
+               return NULL;
+       }
+
+       prop_value = match->value;
+
+       /* Find out the index from memory positions */
+       index = (guint) ((FileNodeProperty *) match -
+                        (FileNodeProperty *) data->properties->data);
+       g_assert (index < data->properties->len);
+
+       g_array_remove_index (data->properties, index);
+
+       return prop_value;
+}
+
 typedef struct {
        TrackerFileSystem *file_system;
        GList *list;
diff --git a/src/libtracker-miner/tracker-file-system.h b/src/libtracker-miner/tracker-file-system.h
index c80b1e5..dc3e724 100644
--- a/src/libtracker-miner/tracker-file-system.h
+++ b/src/libtracker-miner/tracker-file-system.h
@@ -93,6 +93,9 @@ gpointer  tracker_file_system_get_property   (TrackerFileSystem  *file_system,
 void      tracker_file_system_unset_property (TrackerFileSystem  *file_system,
                                               GFile              *file,
                                               GQuark              prop);
+gpointer  tracker_file_system_steal_property (TrackerFileSystem *file_system,
+                                              GFile             *file,
+                                              GQuark             prop);
 
 gboolean  tracker_file_system_get_property_full (TrackerFileSystem *file_system,
                                                  GFile             *file,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]