Implement disk filtering for --files.
authorNot Zed <notzed@gmail.com>
Wed, 20 Dec 2023 08:55:18 +0000 (19:25 +1030)
committerNot Zed <notzed@gmail.com>
Wed, 20 Dec 2023 08:55:18 +0000 (19:25 +1030)
Rename -d database option to non-conflicting -b database.

disk-util.c

index 8f2a44d..a2f8c9a 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char **argv) {
        setlocale(LC_ALL, "en_AU.UTF-8");
 
        if (argc == 1) {
-               printf("usage: %s [-d database] options\n"
+               printf("usage: %s [-b database] options\n"
                        " [ -f fileid ]\n"
                        " [ -s seq ]\n"
                        " [ -d diskid ]    selectors\n"
@@ -78,7 +78,7 @@ int main(int argc, char **argv) {
                return 0;
        }
 
-       if (argc > 2 && strcmp(argv[1], "-d") == 0) {
+       if (argc > 2 && strcmp(argv[1], "-b") == 0) {
                dbdir = argv[2];
                argv += 2;
                argc -= 2;
@@ -131,6 +131,8 @@ int main(int argc, char **argv) {
                        dbscan scan;
 
                        for (dbfile *file = dbscan_file(tx, &scan, db, fileid); file; file = dbscan_file_next(&scan)) {
+                               if (diskid && file->diskid != diskid)
+                                       continue;
                                printf("%4d %-60s '%s'\n", file->id, file->title, file->path);
                                dbfile_free(file);
                        }