diff options
Diffstat (limited to 'src/duplicate_finder.c')
| -rw-r--r-- | src/duplicate_finder.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/duplicate_finder.c b/src/duplicate_finder.c index c6843f0..51bac49 100644 --- a/src/duplicate_finder.c +++ b/src/duplicate_finder.c @@ -16,6 +16,7 @@ */ #include <stdlib.h> +#include <string.h> #include "trace_macros.h" #include "options.h" @@ -30,6 +31,8 @@ /*=========== FUNCTIONS ===========*/ int analyze_db_content(); int scan (const char *path); +int dump(int argc, char **argv, int pos); + /** * The wrapper around automated DB content analysis. @@ -72,8 +75,45 @@ int analyze_db_content() { /** + * dump requested database content + * @param argv argv array from main() + * @param pos The position where to begin in the array + * @param argc The array size from main() + * + * @return EXIT_SUCCESS on success + * EXIT_FAILURE on failure + */ +int dump(int argc, char **argv, int pos) { + int i = pos; + + if (pos >= argc) { + LOGERR("ERROR: Missing parameter\n"); + return EXIT_FAILURE; + } + + if ( ! dbi_open(option_sqlite_db_name) ) { + return EXIT_FAILURE; + } + + for (i=pos; i<argc; i++) { + if (strcmp("fullpath", argv[i]) == 0) { + dbi_print_fullpaths(stdout); + } + + if (option_show_non_duplicates || + strcmp("fileinfos", argv[i]) == 0) { + dbi_print_fileinfo_resolved(stdout); + } + } + + dbi_close(); + return EXIT_SUCCESS; +} + +/** * Scan the given path... * + * @path path to scan * @return EXIT_SUCCESS on success * EXIT_FAILURE on failure */ @@ -123,6 +163,10 @@ int main(int argc, char **argv) { return scan((path_index == argc) ? "." : argv[path_index] ); } + if (option_mode == MODE_DUMP) { + return dump(argc, argv, path_index); + } + if (option_mode == MODE_ANALYZE_DB) { return analyze_db_content(); } |
