File: meta-get-tree.c

package info (click to toggle)
gvfs 1.46.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 13,592 kB
  • sloc: ansic: 100,472; python: 1,462; xml: 986; sh: 158; makefile: 117
file content (63 lines) | stat: -rw-r--r-- 1,503 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "config.h"
#include "metatree.h"
#include <glib/gstdio.h>

/*static gboolean recursive = FALSE;*/
static gboolean verbose = FALSE;
static gboolean do_pause = FALSE;
static GOptionEntry entries[] =
{
  { "verbose", 'l', 0, G_OPTION_ARG_NONE, &verbose, "Verbose", NULL },
  { "pause", 'p', 0, G_OPTION_ARG_NONE, &do_pause, "Pause", NULL },
  { NULL }
};

int
main (int argc,
      char *argv[])
{
  GError *error = NULL;
  GOptionContext *context;
  MetaLookupCache *cache;
  MetaTree *tree;
  char *tree_path;
  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_path = NULL;
      tree = meta_lookup_cache_lookup_path (cache, argv[i], statbuf.st_dev,
					    FALSE, &tree_path);
      if (tree)
	g_print ("tree: %s (exists: %d), tree path: %s\n", meta_tree_get_filename (tree), meta_tree_exists (tree), tree_path);
      else
	g_print ("tree lookup failed\n");

      if (do_pause)
	{
	  char buffer[1000];
	  g_print ("Pausing, press enter\n");
	  fgets(buffer, sizeof(buffer), stdin);
	}
    }

  return 0;
}