[gvfs/metadata: 9/12] Add test app for meta_lookup_cache_lookup



commit 866e6136cd07ce9fc479809b23b2959d4066c583
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 18 13:56:38 2009 +0200

    Add test app for meta_lookup_cache_lookup

 metadata/Makefile.am     |    8 +++++-
 metadata/meta-get-tree.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index 19c2350..f38be18 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -6,6 +6,7 @@ APPS = 	\
 	meta-ls		\
 	meta-get	\
 	meta-set	\
+	meta-get-tree	\
 	$(NULL)
 
 if HAVE_LIBXML
@@ -32,10 +33,13 @@ meta_ls_LDADD = libmetadata.la
 meta_ls_SOURCES = meta-ls.c
 
 meta_set_LDADD = libmetadata.la
-meta_set_SOURCES = meta-ls.c
+meta_set_SOURCES = meta-set.c
 
 meta_get_LDADD = libmetadata.la
-meta_get_SOURCES = meta-ls.c
+meta_get_SOURCES = meta-get.c
+
+meta_get_tree_LDADD = libmetadata.la
+meta_get_tree_SOURCES = meta-get-tree.c
 
 convert_nautilus_metadata_LDADD = libmetadata.la $(LIBXML_LIBS)
 convert_nautilus_metadata_SOURCES = metadata-nautilus.c
diff --git a/metadata/meta-get-tree.c b/metadata/meta-get-tree.c
new file mode 100644
index 0000000..a5b0d92
--- /dev/null
+++ b/metadata/meta-get-tree.c
@@ -0,0 +1,56 @@
+#include "config.h"
+#include "metatree.h"
+#include <glib/gstdio.h>
+
+/*static gboolean recursive = FALSE;*/
+static gboolean verbose = FALSE;
+static gboolean pause = FALSE;
+static GOptionEntry entries[] =
+{
+  { "verbose", 'l', 0, G_OPTION_ARG_NONE, &verbose, "Verbose", NULL },
+  { "pause", 'p', 0, G_OPTION_ARG_NONE, &pause, "Pause", NULL },
+  { NULL }
+};
+
+int
+main (int argc,
+      char *argv[])
+{
+  GError *error = NULL;
+  GOptionContext *context;
+  MetaLookupCache *cache;
+  MetaTree *tree;
+  struct stat statbuf;
+  int i;
+
+  context = g_option_context_new ("<tree file> <dir in tree> - list entries");
+  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+  if (!g_option_context_parse (context, &argc, &argv, &error))
+    {
+      g_printerr ("option parsing failed: %s\n", error->message);
+      return 1;
+    }
+
+
+  cache = meta_lookup_cache_new ();
+
+  for (i = 1; i < argc; i++)
+    {
+      if (g_lstat (argv[i], &statbuf) != 0)
+	{
+	  g_printerr ("can't stat %s\n", argv[i]);
+	  return 1;
+	}
+      
+      tree = meta_lookup_cache_lookup (cache, argv[i], statbuf.st_dev);
+
+      if (pause)
+	{
+	  char buffer[1000];
+	  g_print ("Pausing, press enter\n");
+	  gets(buffer);
+	}
+    }
+
+  return 0;
+}



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