]> git.tue.mpg.de Git - adu.git/commitdiff
Add the --print-base-dir option.
authorAndre Noll <maan@systemlinux.org>
Tue, 3 Jun 2008 15:52:08 +0000 (17:52 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 3 Jun 2008 15:52:08 +0000 (17:52 +0200)
adu.ggo
select.c

diff --git a/adu.ggo b/adu.ggo
index d3dbfdef315330431bd1ccad142c558aea0decf4..a46de259348a5adddbf91f451902a1b0d1e0b9f3 100644 (file)
--- a/adu.ggo
+++ b/adu.ggo
@@ -204,6 +204,16 @@ details="
        format.
 "
 
+option "print-base-dir" -
+#~~~~~~~~~~~~~~~~~~~~~~~~
+"whether to include the base-dir in the output"
+flag off
+details="
+       If this flag is given, all directories printed are prefixed
+       with the base directory. The default is to print paths relative
+       to the base dir.
+"
+
 option "no-headers" -
 #~~~~~~~~~~~~~~~~~~~~
 "supress descriptions for listings/tables"
index 59755a66e9a1f119f0ffe28042ae4b8097f26d35..00b03258d5015d89a387d40ee41e7cbaca3478a2 100644 (file)
--- a/select.c
+++ b/select.c
@@ -116,26 +116,30 @@ static int get_dir_name_by_number(uint64_t *dirnum, char **name)
        char *result = NULL, *tmp;
        struct osl_row *row;
        uint64_t val = *dirnum;
-       struct osl_object obj = {.data = &val, .size = sizeof(val)};
+       struct osl_object obj;
        int ret;
 
 again:
+       obj.data = &val;
+       obj.size = sizeof(val);
        ret = osl(osl_get_row(dir_table, DT_NUM, &obj, &row));
        if (ret < 0)
                goto out;
-       ret = osl(osl_get_object(dir_table, row, DT_NAME, &obj));
-       if (ret < 0)
-               goto out;
-       if (result) {
-               tmp = make_message("%s/%s", (char *)obj.data, result);
-               free(result);
-               result = tmp;
-       } else
-               result = adu_strdup((char *)obj.data);
        ret = osl(osl_get_object(dir_table, row, DT_PARENT_NUM, &obj));
        if (ret < 0)
                goto out;
        val = *(uint64_t *)obj.data;
+       ret = osl(osl_get_object(dir_table, row, DT_NAME, &obj));
+       if (ret < 0)
+               goto out;
+       if (val || conf.print_base_dir_given) {
+               if (result) {
+                       tmp = make_message("%s/%s", (char *)obj.data, result);
+                       free(result);
+                       result = tmp;
+               } else
+                       result = adu_strdup((char *)obj.data);
+       }
        if (val)
                goto again;
 out: