/*
- * finddup is a simple utility to display the files and directories
- * according to their total disk occupancy.
+ * finddup is a simple utility find duplicated files, files common to
+ * several directories, or files present in one directory and not in
+ * another one.
*
* Copyright (c) 2010 Francois Fleuret
* Written by Francois Fleuret <francois@fleuret.org>
*
*/
+#define VERSION_NUMBER "0.5"
+
#define _BSD_SOURCE
#include <sys/types.h>
struct file_with_size *node1, *node2;
int not_in, found;
- if(dirname2[0] == '^') {
+ if(strncmp(dirname2, "not:", 4) == 0) {
not_in = 1;
- dirname2++;
+ dirname2 += 4;
} else {
not_in = 0;
}
file_list_delete(list2);
}
+void print_help(FILE *out) {
+ fprintf(out, "Usage: finddup [OPTION]... DIR1 [[not:]DIR2]\n");
+ fprintf(out, "Version %s (%s)\n", VERSION_NUMBER, UNAME);
+ fprintf(out, "Without DIR2, lists duplicated files found in DIR1. With DIR2, lists files common to both directories. With the not: prefix, lists files found in DIR1 which do not exist in DIR2.\n");
+ fprintf(out, "\n");
+ fprintf(out, " -h show this help.\n");
+ fprintf(out, " -r show the real file paths.\n");
+ fprintf(out, "\n");
+ fprintf(out, "Report bugs and comments to <francois@fleuret.org>\n");
+}
+
/**********************************************************************/
int main(int argc, char **argv) {
switch (c) {
case 'h':
- printf("Usage: finddup [OPTION]... [FILE]...\n");
- printf("Report bugs and comments to <francois@fleuret.org>\n");
+ print_help(stdout);
exit(EXIT_SUCCESS);
break;
} else if(optind < argc) {
start(argv[optind], argv[optind]);
} else {
- fprintf(stderr, "%s [OPTIONS] <dir1> [[^]<dir2>]\n", argv[0]);
+ print_help(stderr);
exit(EXIT_FAILURE);
}