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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#include "config.h"
#include "metatree.h"
/*static gboolean recursive = FALSE;*/
static gboolean verbose = FALSE;
static GOptionEntry entries[] =
{
{ "verbose", 'l', 0, G_OPTION_ARG_NONE, &verbose, "Verbose", NULL },
/* { "recursive", 'r', 0, G_OPTION_ARG_NONE, &recursive, "Recursively list", NULL }, */
{ NULL }
};
static gboolean
print_dir (const char *name,
guint64 last_changed,
gboolean has_children,
gboolean has_data,
gpointer user_data)
{
if (verbose)
g_print ("%-16s %s%s %"G_GUINT64_FORMAT"\n",
name,
has_children?"c":" ",
has_data?"d":" ",
last_changed);
else
g_print ("%s\n", name);
return TRUE;
}
static void
dir (MetaTree *tree,
const char *path)
{
meta_tree_enumerate_dir (tree, path,
print_dir, NULL);
}
int
main (int argc,
char *argv[])
{
MetaTree *tree;
GError *error = NULL;
GOptionContext *context;
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;
}
if (argc < 3)
{
if (argc < 2)
g_printerr ("No metadata tree specified\n");
else
g_printerr ("no dir specified\n");
return 1;
}
tree = meta_tree_open (argv[1], TRUE);
if (tree == NULL)
{
g_printerr ("can't open metadata tree %s\n", argv[1]);
return 1;
}
for (i = 2; i < argc; i++)
{
if (argc > 3)
g_print ("%s:\n", argv[i]);
dir (tree, argv[i]);
}
return 0;
}
|