diff -Nru fdupes-1.51/CHANGES fdupes-1.6.1/CHANGES --- fdupes-1.51/CHANGES 2013-04-20 18:01:12.000000000 +0000 +++ fdupes-1.6.1/CHANGES 2016-08-21 04:54:46.000000000 +0000 @@ -6,6 +6,25 @@ those who've otherwise worked on that item. For a list of contributors names and identifiers please see the CONTRIBUTORS file. +Changes from 1.6.0 to 1.6.1: + +- Fix 'invalid option' error for -I. [AL] + +Changes from 1.51 to 1.6.0: + +- Add --nohidden option. [MC] +- Add --permissions option. [MV] +- Add --order option. [SB] +- Add --reverse option. [AL] +- Add --immediate option. [AL] +- Speed up file comparison. [SB, ST] +- Fix bug where fdupes fails to consistently ignore hardlinks, depending on + file processing order, when F_CONSIDERHARDLINKS flag is not set. [AL] +- Fix bug in is_hardlink(): Proper traversal of duplicates is done via + dupe->duplicates, not via dupe->next. [AL] +- Revise md5.c to compile under OSX. [TH] +- Remove EXTERNAL_MD5 configuration option. [ID] +- Various other changes (see git log). Changes from 1.50 to 1.51 diff -Nru fdupes-1.51/CONTRIBUTORS fdupes-1.6.1/CONTRIBUTORS --- fdupes-1.51/CONTRIBUTORS 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/CONTRIBUTORS 2016-08-21 04:54:46.000000000 +0000 @@ -2,17 +2,22 @@ of fdupes. Please see the CHANGES file for detailed information on their contributions. Names are listed in alphabetical order. - [AB] Adrian Bridgett (adrian.bridgett@iname.com) - [AL] Adrian Lopez (adrian2@caribe.net) -[CHL] Charles Longeau (chl@tuxfamily.org) + [AB] Adrian Bridgett + [AL] Adrian Lopez +[CHL] Charles Longeau [FD] Frank DENIS, a.k.a. Jedi/Sector One, a.k.a. - DJ Chrysalis (j@4u.net) - [JB] Jean-Baptiste () - [KK] Kresimir Kukulj (madmax@pc-hrvoje.srce.hr) - [LB] Laurent Bonnaud (Laurent.Bonnaud@iut2.upmf-grenoble.fr) - [LM] Luca Montecchiani (m.luca@iname.com) - [LR] Lukas Ruf (lukas@lpr.ch) - [PB] Peter Bray (Sydney, Australia) -[SSD] Steven S. Dick (ssd@nevets.oau.org) - + DJ Chrysalis + [JB] Jean-Baptiste + [KK] Kresimir Kukulj + [LB] Laurent Bonnaud + [LM] Luca Montecchiani + [LR] Lukas Ruf + [PB] Peter Bray (Sydney, Australia) +[SSD] Steven S. Dick + [MC] Maximiliano Curia + [MV] Michal Vyskocil + [SB] Stefan BrĂ¼ns + [ST] Sandro Tosi + [ID] Ivan Diorditsa + [TH] Tom Hoover \ No newline at end of file diff -Nru fdupes-1.51/debian/changelog fdupes-1.6.1/debian/changelog --- fdupes-1.51/debian/changelog 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/changelog 2016-08-29 17:49:26.000000000 +0000 @@ -1,6 +1,23 @@ +fdupes (1:1.6.1-1) unstable; urgency=medium + + * New upstream release, with new version schema x.y.z; Closes: #670631 + * debian/{control, copyright} + - update upstream homepage location + * debian/watch + - point to github for releases + * debian/patches/01-restore-pristine-code.patch + - drop, importing the new upstream release effectively removed the custom + changes to the code this patch reverted + * debian/patches/* + - drop all patches, merged upstream + * debian/control + - use HTTPS in Vcs-* fields + - bump tandards-Version to 3.9.8 (no changes needed) + + -- Sandro Tosi Mon, 29 Aug 2016 18:49:26 +0100 + fdupes (1.51-1) unstable; urgency=medium - * New upstream release * debian/watch - point to Google Code * debian/patches/* diff -Nru fdupes-1.51/debian/control fdupes-1.6.1/debian/control --- fdupes-1.51/debian/control 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/control 2016-08-29 17:49:26.000000000 +0000 @@ -3,10 +3,10 @@ Priority: optional Maintainer: Sandro Tosi Build-Depends: debhelper (>= 9) -Standards-Version: 3.9.5 -Homepage: http://code.google.com/p/fdupes/ -Vcs-Git: git://anonscm.debian.org/users/morph/fdupes.git -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=users/morph/fdupes.git +Standards-Version: 3.9.8 +Homepage: https://github.com/adrianlopezroche/fdupes +Vcs-Git: https://alioth.debian.org/anonscm/git/users/morph/fdupes.git +Vcs-Browser: https://anonscm.debian.org/gitweb/?p=users/morph/fdupes.git Package: fdupes Architecture: any diff -Nru fdupes-1.51/debian/copyright fdupes-1.6.1/debian/copyright --- fdupes-1.51/debian/copyright 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/copyright 2016-08-29 17:49:26.000000000 +0000 @@ -1,6 +1,6 @@ This package was debianized by Adrian Bridgett -It was downloaded from http://code.google.com/p/fdupes/ +It was downloaded from https://github.com/adrianlopezroche/fdupes Upstream Author: diff -Nru fdupes-1.51/debian/patches/01-restore-pristine-code.patch fdupes-1.6.1/debian/patches/01-restore-pristine-code.patch --- fdupes-1.51/debian/patches/01-restore-pristine-code.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/01-restore-pristine-code.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -From: Sandro Tosi -Subject: New patch generated from fdupes 1.40-4 diff.gz - -diff -urNad fdupes~/fdupes.c fdupes/fdupes.c ---- fdupes~/fdupes.c 2008-03-17 20:12:35.000000000 +0100 -+++ fdupes/fdupes.c 2008-03-18 00:03:06.798118530 +0100 -@@ -492,7 +492,10 @@ - else { - if (checktree->file->crcpartial == NULL) { - crcsignature = getcrcpartialsignature(checktree->file->d_name); -- if (crcsignature == NULL) return NULL; -+ if (crcsignature == NULL) { -+ errormsg ("cannot read file %s\n", checktree->file->d_name); -+ return NULL; -+ } - - checktree->file->crcpartial = (char*) malloc(strlen(crcsignature)+1); - if (checktree->file->crcpartial == NULL) { -@@ -504,7 +507,10 @@ - - if (file->crcpartial == NULL) { - crcsignature = getcrcpartialsignature(file->d_name); -- if (crcsignature == NULL) return NULL; -+ if (crcsignature == NULL) { -+ errormsg ("cannot read file %s\n", file->d_name); -+ return NULL; -+ } - - file->crcpartial = (char*) malloc(strlen(crcsignature)+1); - if (file->crcpartial == NULL) { -@@ -577,8 +583,8 @@ - - int confirmmatch(FILE *file1, FILE *file2) - { -- unsigned char c1 = 0; -- unsigned char c2 = 0; -+ unsigned char c1[CHUNK_SIZE]; -+ unsigned char c2[CHUNK_SIZE]; - size_t r1; - size_t r2; - -@@ -586,14 +592,13 @@ - fseek(file2, 0, SEEK_SET); - - do { -- r1 = fread(&c1, sizeof(c1), 1, file1); -- r2 = fread(&c2, sizeof(c2), 1, file2); -+ r1 = fread(c1, 1, sizeof(c1), file1); -+ r2 = fread(c2, 1, sizeof(c2), file2); - -- if (c1 != c2) return 0; /* file contents are different */ -- } while (r1 && r2); -+ if (r1 != r2) return 0; /* file lengths are different */ -+ if (memcmp (c1, c2, r1)) return 0; /* file contents are different */ -+ } while (r2); - -- if (r1 != r2) return 0; /* file lengths are different */ -- - return 1; - } - diff -Nru fdupes-1.51/debian/patches/07-fix-manpage.patch fdupes-1.6.1/debian/patches/07-fix-manpage.patch --- fdupes-1.51/debian/patches/07-fix-manpage.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/07-fix-manpage.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -From: Sandro Tosi -Subject: Added to escape minus signs in manpage (lintian warning) - -diff -urNad fdupes~/fdupes.1 fdupes/fdupes.1 ---- fdupes~/fdupes.1 2008-03-17 20:12:35.000000000 +0100 -+++ fdupes/fdupes.1 2008-03-18 23:30:49.051348038 +0100 -@@ -53,7 +53,7 @@ - below) - .TP - .B -N --noprompt --when used together with --delete, preserve the first file in each -+when used together with \-\-delete, preserve the first file in each - set of duplicates and delete the others without prompting the user - .TP - .B -v --version diff -Nru fdupes-1.51/debian/patches/10-bts353789-manpage-typo.patch fdupes-1.6.1/debian/patches/10-bts353789-manpage-typo.patch --- fdupes-1.51/debian/patches/10-bts353789-manpage-typo.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/10-bts353789-manpage-typo.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -From: A Costa -Subject: Fix a typo in the manpage - -diff -urNad fdupes~/fdupes.1 fdupes/fdupes.1 ---- fdupes~/fdupes.1 2008-03-17 20:12:35.000000000 +0100 -+++ fdupes/fdupes.1 2008-03-18 07:33:03.652581590 +0100 -@@ -84,7 +84,7 @@ - .B fdupes: error invoking md5sum - it means the program has been compiled to use an external - program to calculate MD5 signatures (otherwise, fdupes uses --interal routines for this purpose), and an error has occurred -+internal routines for this purpose), and an error has occurred - while attempting to execute it. If this is the case, the - specified program should be properly installed prior - to running fdupes. diff -Nru fdupes-1.51/debian/patches/30-bts481809-manpage-summarize.patch fdupes-1.6.1/debian/patches/30-bts481809-manpage-summarize.patch --- fdupes-1.51/debian/patches/30-bts481809-manpage-summarize.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/30-bts481809-manpage-summarize.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -From: Sandro Tosi -Subject: BTS #481809: add --summarize to manpage - -diff -urNad fdupes~/fdupes.1 fdupes/fdupes.1 ---- fdupes~/fdupes.1 2008-07-03 08:54:35.238410127 +0200 -+++ fdupes/fdupes.1 2008-07-03 08:56:38.653443151 +0200 -@@ -44,6 +44,9 @@ - .B -S --size - show size of duplicate files - .TP -+.B -m --summarize -+summarize duplicate files information -+.TP - .B -q --quiet - hide progress indicator - .TP diff -Nru fdupes-1.51/debian/patches/40-bts511702-nohidden-support.patch fdupes-1.6.1/debian/patches/40-bts511702-nohidden-support.patch --- fdupes-1.51/debian/patches/40-bts511702-nohidden-support.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/40-bts511702-nohidden-support.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -From: -Subject: Adds --nohidden support - -diff -urNad fdupes-1.50-PR2~/fdupes.c fdupes-1.50-PR2/fdupes.c ---- fdupes-1.50-PR2~/fdupes.c 2009-01-13 14:13:33.000000000 -0200 -+++ fdupes-1.50-PR2/fdupes.c 2009-01-13 14:14:14.000000000 -0200 -@@ -31,6 +31,7 @@ - #endif - #include - #include -+#include - - #ifndef EXTERNAL_MD5 - #include "md5/md5.h" -@@ -51,6 +52,7 @@ - #define F_RECURSEAFTER 0x0200 - #define F_NOPROMPT 0x0400 - #define F_SUMMARIZEMATCHES 0x0800 -+#define F_EXCLUDEHIDDEN 0x1000 - - char *program_name; - -@@ -240,6 +242,7 @@ - struct stat linfo; - static int progress = 0; - static char indicator[] = "-\\|/"; -+ char *fullname, *name; - - cd = opendir(dir); - -@@ -285,6 +288,17 @@ - strcat(newfile->d_name, "/"); - strcat(newfile->d_name, dirinfo->d_name); - -+ if (ISFLAG(flags, F_EXCLUDEHIDDEN)) { -+ fullname = strdup(newfile->d_name); -+ name = basename(fullname); -+ if (name[0] == '.' && strcmp(name, ".") && strcmp(name, "..") ) { -+ free(newfile->d_name); -+ free(newfile); -+ continue; -+ } -+ free(fullname); -+ } -+ - if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) { - free(newfile->d_name); - free(newfile); -@@ -945,6 +959,7 @@ - printf(" \tdisk area they are treated as non-duplicates; this\n"); - printf(" \toption will change this behavior\n"); - printf(" -n --noempty \texclude zero-length files from consideration\n"); -+ printf(" -A --nohidden \texclude hidden files from consideration\n"); - printf(" -f --omitfirst \tomit the first file in each set of matches\n"); - printf(" -1 --sameline \tlist each set of matches on a single line\n"); - printf(" -S --size \tshow size of duplicate files\n"); -@@ -996,6 +1011,7 @@ - { "hardlinks", 0, 0, 'H' }, - { "relink", 0, 0, 'l' }, - { "noempty", 0, 0, 'n' }, -+ { "nohidden", 0, 0, 'A' }, - { "delete", 0, 0, 'd' }, - { "version", 0, 0, 'v' }, - { "help", 0, 0, 'h' }, -@@ -1013,7 +1029,7 @@ - - oldargv = cloneargs(argc, argv); - -- while ((opt = GETOPT(argc, argv, "frRq1Ss::HlndvhNm" -+ while ((opt = GETOPT(argc, argv, "frRq1Ss::HlnAdvhNm" - #ifndef OMIT_GETOPT_LONG - , long_options, NULL - #endif -@@ -1046,6 +1062,9 @@ - case 'n': - SETFLAG(flags, F_EXCLUDEEMPTY); - break; -+ case 'A': -+ SETFLAG(flags, F_EXCLUDEHIDDEN); -+ break; - case 'd': - SETFLAG(flags, F_DELETEFILES); - break; - -diff -urNad fdupes~/fdupes.1 fdupes/fdupes.1 ---- fdupes~/fdupes.1 2009-01-13 18:34:55.770835374 +0100 -+++ fdupes/fdupes.1 2009-01-13 18:36:08.510834538 +0100 -@@ -38,6 +38,9 @@ - .B -f --omitfirst - omit the first file in each set of matches - .TP -+.B -A --nohidden -+exclude hidden files from consideration -+.TP - .B -1 --sameline - list each set of matches on a single line - .TP diff -Nru fdupes-1.51/debian/patches/50-bts284274-hardlinkreplace.patch fdupes-1.6.1/debian/patches/50-bts284274-hardlinkreplace.patch --- fdupes-1.51/debian/patches/50-bts284274-hardlinkreplace.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/50-bts284274-hardlinkreplace.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,223 +0,0 @@ -From: -Subject: Replace duplicate files with hardlinks - -Index: fdupes/fdupes.1 -=================================================================== ---- fdupes.orig/fdupes.1 2012-04-25 12:36:33.933441833 +0200 -+++ fdupes/fdupes.1 2012-04-25 12:37:56.931836469 +0200 -@@ -58,10 +58,17 @@ - .B CAVEATS - below) - .TP -+.B -L --linkhard -+replace all duplicate files with hardlinks to the -+first file in each set of duplicates -+.TP - .B -N --noprompt - when used together with \-\-delete, preserve the first file in each - set of duplicates and delete the others without prompting the user - .TP -+.B -D --debug -+provide debugging information -+.TP - .B -v --version - display fdupes version - .TP -Index: fdupes/fdupes.c -=================================================================== ---- fdupes.orig/fdupes.c 2012-04-25 12:36:33.933441833 +0200 -+++ fdupes/fdupes.c 2012-04-25 12:35:48.248527200 +0200 -@@ -53,6 +53,8 @@ - #define F_NOPROMPT 0x0400 - #define F_SUMMARIZEMATCHES 0x0800 - #define F_EXCLUDEHIDDEN 0x1000 -+#define F_HARDLINKFILES 0x2000 -+#define F_DEBUGINFO 0x4000 - - char *program_name; - -@@ -881,6 +883,87 @@ - free(preservestr); - } - -+void hardlinkfiles(file_t *files, int debug) -+{ -+ int counter; -+ int groups = 0; -+ int curgroup = 0; -+ file_t *tmpfile; -+ file_t *curfile; -+ file_t **dupelist; -+ int max = 0; -+ int x = 0; -+ -+ curfile = files; -+ -+ while (curfile) { -+ if (curfile->hasdupes) { -+ counter = 1; -+ groups++; -+ -+ tmpfile = curfile->duplicates; -+ while (tmpfile) { -+ counter++; -+ tmpfile = tmpfile->duplicates; -+ } -+ -+ if (counter > max) max = counter; -+ } -+ -+ curfile = curfile->next; -+ } -+ -+ max++; -+ -+ dupelist = (file_t**) malloc(sizeof(file_t*) * max); -+ -+ if (!dupelist) { -+ errormsg("out of memory\n"); -+ exit(1); -+ } -+ -+ while (files) { -+ if (files->hasdupes) { -+ curgroup++; -+ counter = 1; -+ dupelist[counter] = files; -+ -+ if (debug) printf("[%d] %s\n", counter, files->d_name); -+ -+ tmpfile = files->duplicates; -+ -+ while (tmpfile) { -+ dupelist[++counter] = tmpfile; -+ if (debug) printf("[%d] %s\n", counter, tmpfile->d_name); -+ tmpfile = tmpfile->duplicates; -+ } -+ -+ if (debug) printf("\n"); -+ -+ /* preserve only the first file */ -+ printf(" [+] %s\n", dupelist[1]->d_name); -+ for (x = 2; x <= counter; x++) { -+ if (unlink(dupelist[x]->d_name) == 0) { -+ if ( link(dupelist[1]->d_name, dupelist[x]->d_name) == 0 ) { -+ printf(" [h] %s\n", dupelist[x]->d_name); -+ } else { -+ printf("-- unable to create a hardlink for the file: %s\n", strerror(errno)); -+ printf(" [!] %s ", dupelist[x]->d_name); -+ } -+ } else { -+ printf(" [!] %s ", dupelist[x]->d_name); -+ printf("-- unable to delete the file!\n"); -+ } -+ } -+ printf("\n"); -+ } -+ -+ files = files->next; -+ } -+ -+ free(dupelist); -+} -+ - int sort_pairs_by_arrival(file_t *f1, file_t *f2) - { - if (f2->duplicates != 0) -@@ -971,10 +1054,13 @@ - printf(" \twith -s or --symlinks, or when specifying a\n"); - printf(" \tparticular directory more than once; refer to the\n"); - printf(" \tfdupes documentation for additional information\n"); -- //printf(" -l --relink \t(description)\n"); -+ /* printf(" -r --dlink \t(description)\n"); */ -+ printf(" -L --linkhard \thardlink duplicate files to the first file in\n"); -+ printf(" \teach set of duplicates without prompting the user\n"); - printf(" -N --noprompt \ttogether with --delete, preserve the first file in\n"); - printf(" \teach set of duplicates and delete the rest without\n"); - printf(" \twithout prompting the user\n"); -+ printf(" -D --debug \tenable debugging information\n"); - printf(" -v --version \tdisplay fdupes version\n"); - printf(" -h --help \tdisplay this help message\n\n"); - #ifdef OMIT_GETOPT_LONG -@@ -1010,12 +1096,14 @@ - { "symlinks", 0, 0, 's' }, - { "hardlinks", 0, 0, 'H' }, - { "relink", 0, 0, 'l' }, -+ { "linkhard", 0, 0, 'L' }, - { "noempty", 0, 0, 'n' }, - { "nohidden", 0, 0, 'A' }, - { "delete", 0, 0, 'd' }, - { "version", 0, 0, 'v' }, - { "help", 0, 0, 'h' }, - { "noprompt", 0, 0, 'N' }, -+ { "debug", 0, 0, 'D' }, - { "summarize", 0, 0, 'm'}, - { "summary", 0, 0, 'm' }, - { 0, 0, 0, 0 } -@@ -1029,7 +1117,7 @@ - - oldargv = cloneargs(argc, argv); - -- while ((opt = GETOPT(argc, argv, "frRq1Ss::HlnAdvhNm" -+ while ((opt = GETOPT(argc, argv, "frRq1Ss::HlLnAdDvhNm" - #ifndef OMIT_GETOPT_LONG - , long_options, NULL - #endif -@@ -1068,6 +1156,12 @@ - case 'd': - SETFLAG(flags, F_DELETEFILES); - break; -+ case 'L': -+ SETFLAG(flags, F_HARDLINKFILES); -+ break; -+ case 'D': -+ SETFLAG(flags, F_DEBUGINFO); -+ break; - case 'v': - printf("fdupes %s\n", VERSION); - exit(0); -@@ -1102,6 +1196,16 @@ - exit(1); - } - -+ if (ISFLAG(flags, F_HARDLINKFILES) && ISFLAG(flags, F_DELETEFILES)) { -+ errormsg("options --linkhard and --delete are not compatible\n"); -+ exit(1); -+ } -+ -+ if (ISFLAG(flags, F_HARDLINKFILES) && ISFLAG(flags, F_CONSIDERHARDLINKS)) { -+ errormsg("options --linkhard and --hardlinks are not compatible\n"); -+ exit(1); -+ } -+ - if (ISFLAG(flags, F_RECURSEAFTER)) { - firstrecurse = nonoptafter("--recurse:", argc, oldargv, argv, optind); - -@@ -1187,12 +1291,22 @@ - - else - -- if (ISFLAG(flags, F_SUMMARIZEMATCHES)) -- summarizematches(files); -- -- else -+ if (ISFLAG(flags, F_HARDLINKFILES)) -+ if (ISFLAG(flags, F_DEBUGINFO)) -+ hardlinkfiles(files, 1); -+ else -+ hardlinkfiles(files, 0); -+ -+ else { -+ -+ if (ISFLAG(flags, F_SUMMARIZEMATCHES)) -+ summarizematches(files); -+ -+ else - -- printmatches(files); -+ printmatches(files); -+ -+ } - - while (files) { - curfile = files->next; diff -Nru fdupes-1.51/debian/patches/70-bts537138-disambiguate-recurse.patch fdupes-1.6.1/debian/patches/70-bts537138-disambiguate-recurse.patch --- fdupes-1.51/debian/patches/70-bts537138-disambiguate-recurse.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/70-bts537138-disambiguate-recurse.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -From: Sandro Tosi -Subject: Disambiguate the options '--recurse' and '--recurse:' - -diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' fdupes~/fdupes.1 fdupes/fdupes.1 ---- fdupes~/fdupes.1 2010-05-28 21:27:56.776898579 +0200 -+++ fdupes/fdupes.1 2010-05-28 21:35:33.492898800 +0200 -@@ -23,7 +23,8 @@ - .TP - .B -R --recurse: - for each directory given after this option follow subdirectories --encountered within -+encountered within (note the ':' at the end of option; see the -+Examples section below for further explanation) - .TP - .B -s --symlinks - follow symlinked directories -@@ -92,6 +93,15 @@ - .B --sameline - is specified, spaces and backslash characters (\fB\e\fP) appearing - in a filename are preceded by a backslash character. -+ -+.SH EXAMPLES -+.TP -+.B fdupes a --recurse: b -+will follow subdirectories under b, but not those under a. -+.TP -+.B fdupes a --recurse b -+will follow subdirectories under both a and b. -+ - .SH CAVEATS - If fdupes returns with an error message such as - .B fdupes: error invoking md5sum -diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' fdupes~/fdupes.c fdupes/fdupes.c ---- fdupes~/fdupes.c 2010-05-28 21:27:56.800905326 +0200 -+++ fdupes/fdupes.c 2010-05-28 21:37:27.243398155 +0200 -@@ -1037,7 +1037,8 @@ - printf(" -r --recurse \tfor every directory given follow subdirectories\n"); - printf(" \tencountered within\n"); - printf(" -R --recurse: \tfor each directory given after this option follow\n"); -- printf(" \tsubdirectories encountered within\n"); -+ printf(" \tsubdirectories encountered within (note the ':' at\n"); -+ printf(" \tthe end of the option, manpage for more details)\n"); - printf(" -s --symlinks \tfollow symlinks\n"); - printf(" -H --hardlinks \tnormally, when two or more files point to the same\n"); - printf(" \tdisk area they are treated as non-duplicates; this\n"); diff -Nru fdupes-1.51/debian/patches/80-bts719246-set-CC-to-allow-cross-compilation.patch fdupes-1.6.1/debian/patches/80-bts719246-set-CC-to-allow-cross-compilation.patch --- fdupes-1.51/debian/patches/80-bts719246-set-CC-to-allow-cross-compilation.patch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/80-bts719246-set-CC-to-allow-cross-compilation.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Description: allow to specify the CC compiler, to allow for cross-compilation -Author: Eleanor Chen -Origin: vendor -Bug-Debian: http://bugs.debian.org/719246 -Forwarded: not-needed -Last-Update: 2014-01-19 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/Makefile -+++ b/Makefile -@@ -77,7 +77,7 @@ MKDIR = mkdir -p - # - # Make Configuration - # --CC = gcc -+CC ?= gcc - COMPILER_OPTIONS = -Wall -O -g - - CFLAGS= $(COMPILER_OPTIONS) -I. -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(OMIT_GETOPT_LONG) $(FILEOFFSET_64BIT) diff -Nru fdupes-1.51/debian/patches/series fdupes-1.6.1/debian/patches/series --- fdupes-1.51/debian/patches/series 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -01-restore-pristine-code.patch -07-fix-manpage.patch -10-bts353789-manpage-typo.patch -30-bts481809-manpage-summarize.patch -40-bts511702-nohidden-support.patch -#50-bts284274-hardlinkreplace.patch -70-bts537138-disambiguate-recurse.patch -80-bts719246-set-CC-to-allow-cross-compilation.patch diff -Nru fdupes-1.51/debian/watch fdupes-1.6.1/debian/watch --- fdupes-1.51/debian/watch 2014-01-22 22:41:13.000000000 +0000 +++ fdupes-1.6.1/debian/watch 2016-08-29 17:49:26.000000000 +0000 @@ -1,3 +1,3 @@ version=3 -#http://netdial.caribe.net/~adrian2/programs/fdupes-(.*)\.tar\.gz -https://code.google.com/p/fdupes/downloads/list //fdupes.googlecode.com/files/fdupes-(.*)\.tar.gz +opts="filenamemangle=s/(?:.*?)?v?(\d[\d.]*)\.tar\.gz/fdupes-$1.tar.gz/" \ + https://github.com/adrianlopezroche/fdupes/tags (?:.*?/)?v?(\d[\d.]*)\.tar\.gz diff -Nru fdupes-1.51/fdupes.1 fdupes-1.6.1/fdupes.1 --- fdupes-1.51/fdupes.1 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/fdupes.1 2016-08-21 04:54:46.000000000 +0000 @@ -23,7 +23,8 @@ .TP .B -R --recurse: for each directory given after this option follow subdirectories -encountered within +encountered within (note the ':' at the end of option; see the +Examples section below for further explanation) .TP .B -s --symlinks follow symlinked directories @@ -38,12 +39,18 @@ .B -f --omitfirst omit the first file in each set of matches .TP +.B -A --nohidden +exclude hidden files from consideration +.TP .B -1 --sameline list each set of matches on a single line .TP .B -S --size show size of duplicate files .TP +.B -m --summarize +summarize duplicate files information +.TP .B -q --quiet hide progress indicator .TP @@ -53,9 +60,23 @@ below) .TP .B -N --noprompt -when used together with --delete, preserve the first file in each +when used together with \-\-delete, preserve the first file in each set of duplicates and delete the others without prompting the user .TP +.B -I --immediate +delete duplicates as they are encountered, without +grouping into sets; implies --noprompt +.TP +.B -p --permissions +don't consider files with different owner/group or permission bits as duplicates +.TP +.B -o --order\fR=\fIWORD\fR +order files according to WORD: +time - sort by mtime, name - sort by filename +.TP +.B -i --reverse +reverse order while sorting +.TP .B -v --version display fdupes version .TP @@ -79,12 +100,21 @@ .B --sameline is specified, spaces and backslash characters (\fB\e\fP) appearing in a filename are preceded by a backslash character. + +.SH EXAMPLES +.TP +.B fdupes a --recurse: b +will follow subdirectories under b, but not those under a. +.TP +.B fdupes a --recurse b +will follow subdirectories under both a and b. + .SH CAVEATS If fdupes returns with an error message such as .B fdupes: error invoking md5sum it means the program has been compiled to use an external program to calculate MD5 signatures (otherwise, fdupes uses -interal routines for this purpose), and an error has occurred +internal routines for this purpose), and an error has occurred while attempting to execute it. If this is the case, the specified program should be properly installed prior to running fdupes. diff -Nru fdupes-1.51/fdupes.c fdupes-1.6.1/fdupes.c --- fdupes-1.51/fdupes.c 2013-04-20 18:02:18.000000000 +0000 +++ fdupes-1.6.1/fdupes.c 2016-08-21 04:54:46.000000000 +0000 @@ -31,10 +31,9 @@ #endif #include #include +#include -#ifndef EXTERNAL_MD5 #include "md5/md5.h" -#endif #define ISFLAG(a,b) ((a & b) == b) #define SETFLAG(a,b) (a |= b) @@ -51,6 +50,15 @@ #define F_RECURSEAFTER 0x0200 #define F_NOPROMPT 0x0400 #define F_SUMMARIZEMATCHES 0x0800 +#define F_EXCLUDEHIDDEN 0x1000 +#define F_PERMISSIONS 0x2000 +#define F_REVERSE 0x4000 +#define F_IMMEDIATE 0x8000 + +typedef enum { + ORDER_TIME = 0, + ORDER_NAME +} ordertype_t; char *program_name; @@ -62,6 +70,8 @@ #define PARTIAL_MD5_SIZE 4096 +#define MD5_DIGEST_LENGTH 16 + /* TODO: Partial sums (for working with very large files). @@ -83,8 +93,8 @@ typedef struct _file { char *d_name; off_t size; - char *crcpartial; - char *crcsignature; + md5_byte_t *crcpartial; + md5_byte_t *crcsignature; dev_t device; ino_t inode; time_t mtime; @@ -240,6 +250,7 @@ struct stat linfo; static int progress = 0; static char indicator[] = "-\\|/"; + char *fullname, *name; cd = opendir(dir); @@ -285,6 +296,17 @@ strcat(newfile->d_name, "/"); strcat(newfile->d_name, dirinfo->d_name); + if (ISFLAG(flags, F_EXCLUDEHIDDEN)) { + fullname = strdup(newfile->d_name); + name = basename(fullname); + if (name[0] == '.' && strcmp(name, ".") && strcmp(name, "..") ) { + free(newfile->d_name); + free(newfile); + continue; + } + free(fullname); + } + if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) { free(newfile->d_name); free(newfile); @@ -325,20 +347,13 @@ return filecount; } -#ifndef EXTERNAL_MD5 - -/* If EXTERNAL_MD5 is not defined, use L. Peter Deutsch's MD5 library. - */ -char *getcrcsignatureuntil(char *filename, off_t max_read) +md5_byte_t *getcrcsignatureuntil(char *filename, off_t max_read) { - int x; off_t fsize; off_t toread; md5_state_t state; - md5_byte_t digest[16]; + static md5_byte_t digest[MD5_DIGEST_LENGTH]; static md5_byte_t chunk[CHUNK_SIZE]; - static char signature[16*2 + 1]; - char *sigp; FILE *file; md5_init(&state); @@ -356,7 +371,7 @@ } while (fsize > 0) { - toread = (fsize % CHUNK_SIZE) ? (fsize % CHUNK_SIZE) : CHUNK_SIZE; + toread = (fsize >= CHUNK_SIZE) ? CHUNK_SIZE : fsize; if (fread(chunk, toread, 1, file) != 1) { errormsg("error reading from file %s\n", filename); fclose(file); @@ -368,71 +383,44 @@ md5_finish(&state, digest); - sigp = signature; - - for (x = 0; x < 16; x++) { - sprintf(sigp, "%02x", digest[x]); - sigp = strchr(sigp, '\0'); - } - fclose(file); - return signature; + return digest; } -char *getcrcsignature(char *filename) +md5_byte_t *getcrcsignature(char *filename) { return getcrcsignatureuntil(filename, 0); } -char *getcrcpartialsignature(char *filename) +md5_byte_t *getcrcpartialsignature(char *filename) { return getcrcsignatureuntil(filename, PARTIAL_MD5_SIZE); } -#endif /* [#ifndef EXTERNAL_MD5] */ - -#ifdef EXTERNAL_MD5 - -/* If EXTERNAL_MD5 is defined, use md5sum program to calculate signatures. - */ -char *getcrcsignature(char *filename) +int md5cmp(const md5_byte_t *a, const md5_byte_t *b) { - static char signature[256]; - char *command; - char *separator; - FILE *result; - - command = (char*) malloc(strlen(filename)+strlen(EXTERNAL_MD5)+2); - if (command == NULL) { - errormsg("out of memory\n"); - exit(1); - } - - sprintf(command, "%s %s", EXTERNAL_MD5, filename); + int x; - result = popen(command, "r"); - if (result == NULL) { - errormsg("error invoking %s\n", EXTERNAL_MD5); - exit(1); + for (x = 0; x < MD5_DIGEST_LENGTH; ++x) + { + if (a[x] < b[x]) + return -1; + else if (a[x] > b[x]) + return 1; } - - free(command); - if (fgets(signature, 256, result) == NULL) { - errormsg("error generating signature for %s\n", filename); - return NULL; - } - separator = strchr(signature, ' '); - if (separator) *separator = '\0'; + return 0; +} - pclose(result); +void md5copy(md5_byte_t *to, const md5_byte_t *from) +{ + int x; - return signature; + for (x = 0; x < MD5_DIGEST_LENGTH; ++x) + to[x] = from[x]; } -#endif /* [#ifdef EXTERNAL_MD5] */ - void purgetree(filetree_t *checktree) { if (checktree->left != NULL) purgetree(checktree->left); @@ -467,10 +455,51 @@ return 1; } +int same_permissions(char* name1, char* name2) +{ + struct stat s1, s2; + + if (stat(name1, &s1) != 0) return -1; + if (stat(name2, &s2) != 0) return -1; + + return (s1.st_mode == s2.st_mode && + s1.st_uid == s2.st_uid && + s1.st_gid == s2.st_gid); +} + +int is_hardlink(filetree_t *checktree, file_t *file) +{ + file_t *dupe; + ino_t inode; + dev_t device; + + inode = getinode(file->d_name); + device = getdevice(file->d_name); + + if ((inode == checktree->file->inode) && + (device == checktree->file->device)) + return 1; + + if (checktree->file->hasdupes) + { + dupe = checktree->file->duplicates; + + do { + if ((inode == dupe->inode) && + (device == dupe->device)) + return 1; + + dupe = dupe->duplicates; + } while (dupe != NULL); + } + + return 0; +} + file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file) { int cmpresult; - char *crcsignature; + md5_byte_t *crcsignature; off_t fsize; /* If device and inode fields are equal one of the files is a @@ -479,9 +508,8 @@ duplicates unless the user specifies otherwise. */ - if (!ISFLAG(flags, F_CONSIDERHARDLINKS) && (getinode(file->d_name) == - checktree->file->inode) && (getdevice(file->d_name) == - checktree->file->device)) return NULL; + if (!ISFLAG(flags, F_CONSIDERHARDLINKS) && is_hardlink(checktree, file)) + return NULL; fsize = filesize(file->d_name); @@ -489,32 +517,42 @@ cmpresult = -1; else if (fsize > checktree->file->size) cmpresult = 1; + else + if (ISFLAG(flags, F_PERMISSIONS) && + !same_permissions(file->d_name, checktree->file->d_name)) + cmpresult = -1; else { if (checktree->file->crcpartial == NULL) { crcsignature = getcrcpartialsignature(checktree->file->d_name); - if (crcsignature == NULL) return NULL; + if (crcsignature == NULL) { + errormsg ("cannot read file %s\n", checktree->file->d_name); + return NULL; + } - checktree->file->crcpartial = (char*) malloc(strlen(crcsignature)+1); + checktree->file->crcpartial = (md5_byte_t*) malloc(MD5_DIGEST_LENGTH * sizeof(md5_byte_t)); if (checktree->file->crcpartial == NULL) { errormsg("out of memory\n"); exit(1); } - strcpy(checktree->file->crcpartial, crcsignature); + md5copy(checktree->file->crcpartial, crcsignature); } if (file->crcpartial == NULL) { crcsignature = getcrcpartialsignature(file->d_name); - if (crcsignature == NULL) return NULL; + if (crcsignature == NULL) { + errormsg ("cannot read file %s\n", file->d_name); + return NULL; + } - file->crcpartial = (char*) malloc(strlen(crcsignature)+1); + file->crcpartial = (md5_byte_t*) malloc(MD5_DIGEST_LENGTH * sizeof(md5_byte_t)); if (file->crcpartial == NULL) { errormsg("out of memory\n"); exit(1); } - strcpy(file->crcpartial, crcsignature); + md5copy(file->crcpartial, crcsignature); } - cmpresult = strcmp(file->crcpartial, checktree->file->crcpartial); + cmpresult = md5cmp(file->crcpartial, checktree->file->crcpartial); /*if (cmpresult != 0) errormsg(" on %s vs %s\n", file->d_name, checktree->file->d_name);*/ if (cmpresult == 0) { @@ -522,27 +560,27 @@ crcsignature = getcrcsignature(checktree->file->d_name); if (crcsignature == NULL) return NULL; - checktree->file->crcsignature = (char*) malloc(strlen(crcsignature)+1); + checktree->file->crcsignature = (md5_byte_t*) malloc(MD5_DIGEST_LENGTH * sizeof(md5_byte_t)); if (checktree->file->crcsignature == NULL) { errormsg("out of memory\n"); exit(1); } - strcpy(checktree->file->crcsignature, crcsignature); + md5copy(checktree->file->crcsignature, crcsignature); } if (file->crcsignature == NULL) { crcsignature = getcrcsignature(file->d_name); if (crcsignature == NULL) return NULL; - file->crcsignature = (char*) malloc(strlen(crcsignature)+1); + file->crcsignature = (md5_byte_t*) malloc(MD5_DIGEST_LENGTH * sizeof(md5_byte_t)); if (file->crcsignature == NULL) { errormsg("out of memory\n"); exit(1); } - strcpy(file->crcsignature, crcsignature); + md5copy(file->crcsignature, crcsignature); } - cmpresult = strcmp(file->crcsignature, checktree->file->crcsignature); + cmpresult = md5cmp(file->crcsignature, checktree->file->crcsignature); /*if (cmpresult != 0) errormsg("P on %s vs %s\n", file->d_name, checktree->file->d_name); else errormsg("P F on %s vs %s\n", file->d_name, @@ -577,8 +615,8 @@ int confirmmatch(FILE *file1, FILE *file2) { - unsigned char c1 = 0; - unsigned char c2 = 0; + unsigned char c1[CHUNK_SIZE]; + unsigned char c2[CHUNK_SIZE]; size_t r1; size_t r2; @@ -586,14 +624,13 @@ fseek(file2, 0, SEEK_SET); do { - r1 = fread(&c1, sizeof(c1), 1, file1); - r2 = fread(&c2, sizeof(c2), 1, file2); + r1 = fread(c1, sizeof(unsigned char), sizeof(c1), file1); + r2 = fread(c2, sizeof(unsigned char), sizeof(c2), file2); - if (c1 != c2) return 0; /* file contents are different */ - } while (r1 && r2); + if (r1 != r2) return 0; /* file lengths are different */ + if (memcmp (c1, c2, r1)) return 0; /* file contents are different */ + } while (r2); - if (r1 != r2) return 0; /* file lengths are different */ - return 1; } @@ -629,7 +666,7 @@ if (numbytes < 1024.0) printf("%d duplicate files (in %d sets), occupying %.0f bytes.\n\n", numfiles, numsets, numbytes); else if (numbytes <= (1000.0 * 1000.0)) - printf("%d duplicate files (in %d sets), occupying %.1f kylobytes\n\n", numfiles, numsets, numbytes / 1000.0); + printf("%d duplicate files (in %d sets), occupying %.1f kilobytes\n\n", numfiles, numsets, numbytes / 1000.0); else printf("%d duplicate files (in %d sets), occupying %.1f megabytes\n\n", numfiles, numsets, numbytes / (1000.0 * 1000.0)); @@ -643,7 +680,7 @@ while (files != NULL) { if (files->hasdupes) { if (!ISFLAG(flags, F_OMITFIRST)) { - if (ISFLAG(flags, F_SHOWSIZE)) printf("%lld byte%seach:\n", files->size, + if (ISFLAG(flags, F_SHOWSIZE)) printf("%lld byte%seach:\n", (long long int)files->size, (files->size != 1) ? "s " : " "); if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &files->d_name); printf("%s%c", files->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n'); @@ -796,7 +833,7 @@ do { printf("Set %d of %d, preserve files [1 - %d, all]", curgroup, groups, counter); - if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%lld byte%seach)", files->size, + if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%lld byte%seach)", (long long int)files->size, (files->size != 1) ? "s " : " "); printf(": "); fflush(stdout); @@ -869,21 +906,26 @@ int sort_pairs_by_arrival(file_t *f1, file_t *f2) { if (f2->duplicates != 0) - return 1; + return !ISFLAG(flags, F_REVERSE) ? 1 : -1; - return -1; + return !ISFLAG(flags, F_REVERSE) ? -1 : 1; } int sort_pairs_by_mtime(file_t *f1, file_t *f2) { if (f1->mtime < f2->mtime) - return -1; + return !ISFLAG(flags, F_REVERSE) ? -1 : 1; else if (f1->mtime > f2->mtime) - return 1; + return !ISFLAG(flags, F_REVERSE) ? 1 : -1; return 0; } +int sort_pairs_by_filename(file_t *f1, file_t *f2) +{ + return strcmp(f1->d_name, f2->d_name); +} + void registerpair(file_t **matchlist, file_t *newmatch, int (*comparef)(file_t *f1, file_t *f2)) { @@ -930,6 +972,38 @@ } } +void deletesuccessor(file_t **existing, file_t *duplicate, + int (*comparef)(file_t *f1, file_t *f2)) +{ + file_t *to_keep; + file_t *to_delete; + + if (comparef(duplicate, *existing) >= 0) + { + to_keep = *existing; + to_delete = duplicate; + } + else + { + to_keep = duplicate; + to_delete = *existing; + + *existing = duplicate; + } + + if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " "); + + printf(" [+] %s\n", to_keep->d_name); + if (remove(to_delete->d_name) == 0) { + printf(" [-] %s\n", to_delete->d_name); + } else { + printf(" [!] %s ", to_delete->d_name); + printf("-- unable to delete file!\n"); + } + + printf("\n"); +} + void help_text() { printf("Usage: fdupes [options] DIRECTORY...\n\n"); @@ -937,12 +1011,14 @@ printf(" -r --recurse \tfor every directory given follow subdirectories\n"); printf(" \tencountered within\n"); printf(" -R --recurse: \tfor each directory given after this option follow\n"); - printf(" \tsubdirectories encountered within\n"); + printf(" \tsubdirectories encountered within (note the ':' at\n"); + printf(" \tthe end of the option, manpage for more details)\n"); printf(" -s --symlinks \tfollow symlinks\n"); printf(" -H --hardlinks \tnormally, when two or more files point to the same\n"); printf(" \tdisk area they are treated as non-duplicates; this\n"); printf(" \toption will change this behavior\n"); printf(" -n --noempty \texclude zero-length files from consideration\n"); + printf(" -A --nohidden \texclude hidden files from consideration\n"); printf(" -f --omitfirst \tomit the first file in each set of matches\n"); printf(" -1 --sameline \tlist each set of matches on a single line\n"); printf(" -S --size \tshow size of duplicate files\n"); @@ -958,6 +1034,13 @@ printf(" -N --noprompt \ttogether with --delete, preserve the first file in\n"); printf(" \teach set of duplicates and delete the rest without\n"); printf(" \tprompting the user\n"); + printf(" -I --immediate \tdelete duplicates as they are encountered, without\n"); + printf(" \tgrouping into sets; implies --noprompt\n"); + printf(" -p --permissions \tdon't consider files with different owner/group or\n"); + printf(" \tpermission bits as duplicates\n"); + printf(" -o --order=BY \tselect sort order for output, linking and deleting; by\n"); + printf(" \tmtime (BY='time'; default) or filename (BY='name')\n"); + printf(" -i --reverse \treverse order while sorting\n"); printf(" -v --version \tdisplay fdupes version\n"); printf(" -h --help \tdisplay this help message\n\n"); #ifdef OMIT_GETOPT_LONG @@ -978,6 +1061,7 @@ int progress = 0; char **oldargv; int firstrecurse; + ordertype_t ordertype = ORDER_TIME; #ifndef OMIT_GETOPT_LONG static struct option long_options[] = @@ -994,12 +1078,17 @@ { "hardlinks", 0, 0, 'H' }, { "relink", 0, 0, 'l' }, { "noempty", 0, 0, 'n' }, + { "nohidden", 0, 0, 'A' }, { "delete", 0, 0, 'd' }, { "version", 0, 0, 'v' }, { "help", 0, 0, 'h' }, { "noprompt", 0, 0, 'N' }, + { "immediate", 0, 0, 'I'}, { "summarize", 0, 0, 'm'}, { "summary", 0, 0, 'm' }, + { "permissions", 0, 0, 'p' }, + { "order", 1, 0, 'o' }, + { "reverse", 0, 0, 'i' }, { 0, 0, 0, 0 } }; #define GETOPT getopt_long @@ -1011,7 +1100,7 @@ oldargv = cloneargs(argc, argv); - while ((opt = GETOPT(argc, argv, "frRq1Ss::HlndvhNm" + while ((opt = GETOPT(argc, argv, "frRq1SsHlnAdvhNImpo:i" #ifndef OMIT_GETOPT_LONG , long_options, NULL #endif @@ -1044,6 +1133,9 @@ case 'n': SETFLAG(flags, F_EXCLUDEEMPTY); break; + case 'A': + SETFLAG(flags, F_EXCLUDEHIDDEN); + break; case 'd': SETFLAG(flags, F_DELETEFILES); break; @@ -1056,9 +1148,28 @@ case 'N': SETFLAG(flags, F_NOPROMPT); break; + case 'I': + SETFLAG(flags, F_IMMEDIATE); + break; case 'm': SETFLAG(flags, F_SUMMARIZEMATCHES); break; + case 'p': + SETFLAG(flags, F_PERMISSIONS); + break; + case 'o': + if (!strcasecmp("name", optarg)) { + ordertype = ORDER_NAME; + } else if (!strcasecmp("time", optarg)) { + ordertype = ORDER_TIME; + } else { + errormsg("invalid value for --order: '%s'\n", optarg); + exit(1); + } + break; + case 'i': + SETFLAG(flags, F_REVERSE); + break; default: fprintf(stderr, "Try `fdupes --help' for more information.\n"); @@ -1134,11 +1245,12 @@ } if (confirmmatch(file1, file2)) { - registerpair(match, curfile, sort_pairs_by_mtime); - - /*match->hasdupes = 1; - curfile->duplicates = match->duplicates; - match->duplicates = curfile;*/ + if (ISFLAG(flags, F_DELETEFILES) && ISFLAG(flags, F_IMMEDIATE)) + deletesuccessor(match, curfile, + (ordertype == ORDER_TIME) ? sort_pairs_by_mtime : sort_pairs_by_filename ); + else + registerpair(match, curfile, + (ordertype == ORDER_TIME) ? sort_pairs_by_mtime : sort_pairs_by_filename ); } fclose(file1); @@ -1164,7 +1276,12 @@ } else { - stdin = freopen("/dev/tty", "r", stdin); + if (freopen("/dev/tty", "r", stdin) == 0) + { + errormsg("could not open terminal for input\n"); + exit(1); + } + deletefiles(files, 1, stdin); } } diff -Nru fdupes-1.51/.gitignore fdupes-1.6.1/.gitignore --- fdupes-1.51/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ fdupes-1.6.1/.gitignore 2016-08-21 04:54:46.000000000 +0000 @@ -0,0 +1,2 @@ +fdupes +*.o diff -Nru fdupes-1.51/Makefile fdupes-1.6.1/Makefile --- fdupes-1.51/Makefile 2013-04-20 17:51:58.000000000 +0000 +++ fdupes-1.6.1/Makefile 2016-08-21 04:54:46.000000000 +0000 @@ -25,13 +25,6 @@ # #OMIT_GETOPT_LONG = -DOMIT_GETOPT_LONG -# -# To use the md5sum program for calculating signatures (instead of the -# built in MD5 message digest routines) uncomment the following -# line (try this if you're having trouble with built in code). -# -#EXTERNAL_MD5 = -DEXTERNAL_MD5=\"md5sum\" - ##################################################################### # Developer Configuration Section # ##################################################################### @@ -56,7 +49,7 @@ # MAN_DIR indicates directory where the fdupes man page is to be # installed. Suggested value is "$(PREFIX)/man/man1" # -MAN_BASE_DIR = $(PREFIX)/man +MAN_BASE_DIR = $(PREFIX)/share/man MAN_DIR = $(MAN_BASE_DIR)/man1 MAN_EXT = 1 @@ -77,10 +70,10 @@ # # Make Configuration # -CC = gcc +CC ?= gcc COMPILER_OPTIONS = -Wall -O -g -CFLAGS= $(COMPILER_OPTIONS) -I. -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(OMIT_GETOPT_LONG) $(FILEOFFSET_64BIT) +CFLAGS= $(COMPILER_OPTIONS) -I. -DVERSION=\"$(VERSION)\" $(OMIT_GETOPT_LONG) $(FILEOFFSET_64BIT) INSTALL_PROGRAM = $(INSTALL) -c -m 0755 INSTALL_DATA = $(INSTALL) -c -m 0644 @@ -100,15 +93,15 @@ all: fdupes fdupes: $(OBJECT_FILES) - $(CC) $(CFLAGS) -o fdupes $(OBJECT_FILES) + $(CC) $(CFLAGS) $(LDFLAGS) -o fdupes $(OBJECT_FILES) installdirs: - test -d $(BIN_DIR) || $(MKDIR) $(BIN_DIR) - test -d $(MAN_DIR) || $(MKDIR) $(MAN_DIR) + test -d $(DESTDIR)$(BIN_DIR) || $(MKDIR) $(DESTDIR)$(BIN_DIR) + test -d $(DESTDIR)$(MAN_DIR) || $(MKDIR) $(DESTDIR)$(MAN_DIR) install: fdupes installdirs - $(INSTALL_PROGRAM) fdupes $(BIN_DIR)/$(PROGRAM_NAME) - $(INSTALL_DATA) fdupes.1 $(MAN_DIR)/$(PROGRAM_NAME).$(MAN_EXT) + $(INSTALL_PROGRAM) fdupes $(DESTDIR)$(BIN_DIR)/$(PROGRAM_NAME) + $(INSTALL_DATA) fdupes.1 $(DESTDIR)$(MAN_DIR)/$(PROGRAM_NAME).$(MAN_EXT) clean: $(RM) $(OBJECT_FILES) diff -Nru fdupes-1.51/Makefile.inc/VERSION fdupes-1.6.1/Makefile.inc/VERSION --- fdupes-1.51/Makefile.inc/VERSION 2013-04-20 18:21:08.000000000 +0000 +++ fdupes-1.6.1/Makefile.inc/VERSION 2016-08-21 04:54:46.000000000 +0000 @@ -2,4 +2,4 @@ # VERSION determines the program's version number. # -VERSION = 1.51 +VERSION = 1.6.1 diff -Nru fdupes-1.51/md5/md5.c fdupes-1.6.1/md5/md5.c --- fdupes-1.51/md5/md5.c 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/md5/md5.c 2016-08-21 04:54:46.000000000 +0000 @@ -35,7 +35,9 @@ contributors chl - Charles Longeau + tom - Tom Hoover + 2015-02-04 tom Added #ifdef __APPLE__ for proper compilation under OSX. 2002-05-31 chl Relocated string.h to avoid memcpy warning. 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). @@ -45,6 +47,19 @@ #include "md5.h" #include +/* endianness check using glibc endian.h */ +#ifdef __APPLE__ +# include +#else +# include +#endif + +#if __BYTE_ORDER == __BIG_ENDIAN +# define ARCH_IS_BIG_ENDIAN 1 +#elif __BYTE_ORDER == __LITTLE_ENDIAN +# define ARCH_IS_BIG_ENDIAN 0 +#endif + #ifdef TEST /* * Compile with -DTEST to create a self-contained executable test program. diff -Nru fdupes-1.51/README fdupes-1.6.1/README --- fdupes-1.51/README 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/README 2016-08-21 04:54:46.000000000 +0000 @@ -11,15 +11,18 @@ -r --recurse for every directory given follow subdirectories encountered within -R --recurse: for each directory given after this option follow - subdirectories encountered within + subdirectories encountered within (note the ':' at + the end of the option, manpage for more details) -s --symlinks follow symlinks -H --hardlinks normally, when two or more files point to the same disk area they are treated as non-duplicates; this option will change this behavior -n --noempty exclude zero-length files from consideration + -A --nohidden exclude hidden files from consideration -f --omitfirst omit the first file in each set of matches -1 --sameline list each set of matches on a single line -S --size show size of duplicate files + -m --summarize summarize dupe information -q --quiet hide progress indicator -d --delete prompt user for files to preserve and delete all others; important: under particular circumstances, @@ -27,6 +30,16 @@ with -s or --symlinks, or when specifying a particular directory more than once; refer to the fdupes documentation for additional information + -N --noprompt together with --delete, preserve the first file in + each set of duplicates and delete the rest without + prompting the user + -I --immediate delete duplicates as they are encountered, without + grouping into sets; implies --noprompt + -p --permissions don't consider files with different owner/group or + permission bits as duplicates + -o --order=BY select sort order for output, linking and deleting; by + mtime (BY='time'; default) or filename (BY='name') + -i --reverse reverse order while sorting -v --version display fdupes version -h --help display this help message diff -Nru fdupes-1.51/.svn/entries fdupes-1.6.1/.svn/entries --- fdupes-1.51/.svn/entries 2013-04-20 17:00:05.000000000 +0000 +++ fdupes-1.6.1/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -12 diff -Nru fdupes-1.51/.svn/format fdupes-1.6.1/.svn/format --- fdupes-1.51/.svn/format 2013-04-20 17:00:05.000000000 +0000 +++ fdupes-1.6.1/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -12 diff -Nru fdupes-1.51/.svn/pristine/08/08c4afaacabe55c58e4299959d27a332f5f0f258.svn-base fdupes-1.6.1/.svn/pristine/08/08c4afaacabe55c58e4299959d27a332f5f0f258.svn-base --- fdupes-1.51/.svn/pristine/08/08c4afaacabe55c58e4299959d27a332f5f0f258.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/08/08c4afaacabe55c58e4299959d27a332f5f0f258.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -The following list, organized by fdupes version, documents changes -to fdupes. Every item on the list includes, inside square brackets, -a list of indentifiers referring to the people who contributed -that particular item. When more than one person is listed the person -who contributed the patch or idea appears first, followed by -those who've otherwise worked on that item. For a list of -contributors names and identifiers please see the CONTRIBUTORS file. - - -Changes from 1.40 to 1.50-PR2 - -- Fixed memory leak. [JB] -- Added "--summarize" option. [AL] -- Added "--recurse:" selective recursion option. [AL] -- Added "--noprompt" option for totally automated deletion of - duplicate files. -- Now sorts duplicates (old to new) for consistent order when - listing or deleteing duplicate files. -- Now tests for early matching of files, which should help speed up - the matching process when large files are involved. -- Added warning whenever a file cannot be deleted. [CHL, AL] -- Fixed bug where some files would not be closed after failure. [AL] -- Fixed bug where confirmmatch() function wouldn't always deal - properly with zero-length files. [AL] -- Fixed bug where progress indicator would not be cleared - when no files were found. [AL] -- Removed experimental red-black tree code (it was slower on - my system than the default code). [AL] -- Modified md5/md5.c to avoid compiler warning. [CHL] -- Changes to fdupes.c for compilation under platforms where - getopt_long is unavailable. [LR, AL] -- Changes to help text for clarity. [AL] -- Various changes and improvements to Makefile. [PB, AL] - -Changes from 1.31 to 1.40 - -- Added option to omit the first file in each group - of matches. [LM, AL] -- Added escaping of filenames containing spaces when - sameline option is specified. [AL] -- Changed version indicator format from "fdupes version X.Y" - to the simpler "fdupes X.Y". [AL] -- Changed ordering of options appearing in the help - text (--help), manpage, and README file. [AL] - -Changes from 1.30 to 1.31 - -- Added interactive option to preserve all files during - delete procedure (something similar was already in - place, but now it's official). [AL] -- Updated delete procedure prompt format. [AL] -- Cosmetic code changes. [AL] - -Changes from 1.20 to 1.30 - -- Added size option to display size of duplicates. [LB, AL] -- Added missing typecast for proper compilation under g++. [LB] -- Better handling of errors occurring during retrieval - of a file's signature. [KK, AL] -- No longer displays an error message when specified - directories contain no files. [AL] -- Added red-black tree structure (experimental compile-time - option, disabled by default). [AL] - -Changes from 1.12 to 1.20 - -- Fixed bug where program would crash when files being - scanned were named pipes or sockets. [FD] -- Fix against security risk resulting from the use of a - temporary file to store md5sum output. [FD, AL] -- Using an external md5sum program is now optional. Started - using L. Peter Deutsh's MD5 library instead. [FD, AL] -- Added hardlinks option to distinguish between hard links - and actual duplicate files. [FD, AL] -- Added noempty option to exclude zero-length files - from consideration [AL] - -Changes from 1.11 to 1.12 - -- Improved handling of extremely long input on preserve - prompt (delete option). [SSD, AL] - -Changes from 1.1 to 1.11 - -- Started checking file sizes before signatures - for better performance. [AB, AL] -- Added fdupes manpage. [AB, AL] - -Changes from 1.0 to 1.1 - -- Added delete option for semi-automatic deletion - of duplicate files. [AL] - diff -Nru fdupes-1.51/.svn/pristine/12/1276bd8f6e7e8f9d3879bdcdf2d2e31c86886466.svn-base fdupes-1.6.1/.svn/pristine/12/1276bd8f6e7e8f9d3879bdcdf2d2e31c86886466.svn-base --- fdupes-1.51/.svn/pristine/12/1276bd8f6e7e8f9d3879bdcdf2d2e31c86886466.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/12/1276bd8f6e7e8f9d3879bdcdf2d2e31c86886466.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -The following people have contributed in some way to the development -of fdupes. Please see the CHANGES file for detailed information -on their contributions. Names are listed in alphabetical order. - - [AB] Adrian Bridgett (adrian.bridgett@iname.com) - [AL] Adrian Lopez (adrian2@caribe.net) -[CHL] Charles Longeau (chl@tuxfamily.org) - [FD] Frank DENIS, a.k.a. - Jedi/Sector One, a.k.a. - DJ Chrysalis (j@4u.net) - [JB] Jean-Baptiste () - [KK] Kresimir Kukulj (madmax@pc-hrvoje.srce.hr) - [LB] Laurent Bonnaud (Laurent.Bonnaud@iut2.upmf-grenoble.fr) - [LM] Luca Montecchiani (m.luca@iname.com) - [LR] Lukas Ruf (lukas@lpr.ch) - [PB] Peter Bray (Sydney, Australia) -[SSD] Steven S. Dick (ssd@nevets.oau.org) - diff -Nru fdupes-1.51/.svn/pristine/1d/1d9037bc7f488901dc068f1df3818084c5125ec1.svn-base fdupes-1.6.1/.svn/pristine/1d/1d9037bc7f488901dc068f1df3818084c5125ec1.svn-base --- fdupes-1.51/.svn/pristine/1d/1d9037bc7f488901dc068f1df3818084c5125ec1.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/1d/1d9037bc7f488901dc068f1df3818084c5125ec1.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1190 +0,0 @@ -/* FDUPES Copyright (c) 1999-2002 Adrian Lopez - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include -#include -#include -#include -#include -#include -#include -#ifndef OMIT_GETOPT_LONG -#include -#endif -#include -#include - -#ifndef EXTERNAL_MD5 -#include "md5/md5.h" -#endif - -#define ISFLAG(a,b) ((a & b) == b) -#define SETFLAG(a,b) (a |= b) - -#define F_RECURSE 0x0001 -#define F_HIDEPROGRESS 0x0002 -#define F_DSAMELINE 0x0004 -#define F_FOLLOWLINKS 0x0008 -#define F_DELETEFILES 0x0010 -#define F_EXCLUDEEMPTY 0x0020 -#define F_CONSIDERHARDLINKS 0x0040 -#define F_SHOWSIZE 0x0080 -#define F_OMITFIRST 0x0100 -#define F_RECURSEAFTER 0x0200 -#define F_NOPROMPT 0x0400 -#define F_SUMMARIZEMATCHES 0x0800 - -char *program_name; - -unsigned long flags = 0; - -#define CHUNK_SIZE 8192 - -#define INPUT_SIZE 256 - -#define PARTIAL_MD5_SIZE 4096 - -/* - -TODO: Partial sums (for working with very large files). - -typedef struct _signature -{ - md5_state_t state; - md5_byte_t digest[16]; -} signature_t; - -typedef struct _signatures -{ - int num_signatures; - signature_t *signatures; -} signatures_t; - -*/ - -typedef struct _file { - char *d_name; - off_t size; - char *crcpartial; - char *crcsignature; - dev_t device; - ino_t inode; - time_t mtime; - int hasdupes; /* true only if file is first on duplicate chain */ - struct _file *duplicates; - struct _file *next; -} file_t; - -typedef struct _filetree { - file_t *file; - struct _filetree *left; - struct _filetree *right; -} filetree_t; - -void errormsg(char *message, ...) -{ - va_list ap; - - va_start(ap, message); - - fprintf(stderr, "\r%40s\r%s: ", "", program_name); - vfprintf(stderr, message, ap); -} - -void escapefilename(char *escape_list, char **filename_ptr) -{ - int x; - int tx; - char *tmp; - char *filename; - - filename = *filename_ptr; - - tmp = (char*) malloc(strlen(filename) * 2 + 1); - if (tmp == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - - for (x = 0, tx = 0; x < strlen(filename); x++) { - if (strchr(escape_list, filename[x]) != NULL) tmp[tx++] = '\\'; - tmp[tx++] = filename[x]; - } - - tmp[tx] = '\0'; - - if (x != tx) { - *filename_ptr = realloc(*filename_ptr, strlen(tmp) + 1); - if (*filename_ptr == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - strcpy(*filename_ptr, tmp); - } -} - -off_t filesize(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return -1; - - return s.st_size; -} - -dev_t getdevice(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return 0; - - return s.st_dev; -} - -ino_t getinode(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return 0; - - return s.st_ino; -} - -time_t getmtime(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return 0; - - return s.st_mtime; -} - -char **cloneargs(int argc, char **argv) -{ - int x; - char **args; - - args = (char **) malloc(sizeof(char*) * argc); - if (args == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - - for (x = 0; x < argc; x++) { - args[x] = (char*) malloc(strlen(argv[x]) + 1); - if (args[x] == NULL) { - free(args); - errormsg("out of memory!\n"); - exit(1); - } - - strcpy(args[x], argv[x]); - } - - return args; -} - -int findarg(char *arg, int start, int argc, char **argv) -{ - int x; - - for (x = start; x < argc; x++) - if (strcmp(argv[x], arg) == 0) - return x; - - return x; -} - -/* Find the first non-option argument after specified option. */ -int nonoptafter(char *option, int argc, char **oldargv, - char **newargv, int optind) -{ - int x; - int targetind; - int testind; - int startat = 1; - - targetind = findarg(option, 1, argc, oldargv); - - for (x = optind; x < argc; x++) { - testind = findarg(newargv[x], startat, argc, oldargv); - if (testind > targetind) return x; - else startat = testind; - } - - return x; -} - -int grokdir(char *dir, file_t **filelistp) -{ - DIR *cd; - file_t *newfile; - struct dirent *dirinfo; - int lastchar; - int filecount = 0; - struct stat info; - struct stat linfo; - static int progress = 0; - static char indicator[] = "-\\|/"; - - cd = opendir(dir); - - if (!cd) { - errormsg("could not chdir to %s\n", dir); - return 0; - } - - while ((dirinfo = readdir(cd)) != NULL) { - if (strcmp(dirinfo->d_name, ".") && strcmp(dirinfo->d_name, "..")) { - if (!ISFLAG(flags, F_HIDEPROGRESS)) { - fprintf(stderr, "\rBuilding file list %c ", indicator[progress]); - progress = (progress + 1) % 4; - } - - newfile = (file_t*) malloc(sizeof(file_t)); - - if (!newfile) { - errormsg("out of memory!\n"); - closedir(cd); - exit(1); - } else newfile->next = *filelistp; - - newfile->device = 0; - newfile->inode = 0; - newfile->crcsignature = NULL; - newfile->crcpartial = NULL; - newfile->duplicates = NULL; - newfile->hasdupes = 0; - - newfile->d_name = (char*)malloc(strlen(dir)+strlen(dirinfo->d_name)+2); - - if (!newfile->d_name) { - errormsg("out of memory!\n"); - free(newfile); - closedir(cd); - exit(1); - } - - strcpy(newfile->d_name, dir); - lastchar = strlen(dir) - 1; - if (lastchar >= 0 && dir[lastchar] != '/') - strcat(newfile->d_name, "/"); - strcat(newfile->d_name, dirinfo->d_name); - - if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) { - free(newfile->d_name); - free(newfile); - continue; - } - - if (stat(newfile->d_name, &info) == -1) { - free(newfile->d_name); - free(newfile); - continue; - } - - if (lstat(newfile->d_name, &linfo) == -1) { - free(newfile->d_name); - free(newfile); - continue; - } - - if (S_ISDIR(info.st_mode)) { - if (ISFLAG(flags, F_RECURSE) && (ISFLAG(flags, F_FOLLOWLINKS) || !S_ISLNK(linfo.st_mode))) - filecount += grokdir(newfile->d_name, filelistp); - free(newfile->d_name); - free(newfile); - } else { - if (S_ISREG(linfo.st_mode) || (S_ISLNK(linfo.st_mode) && ISFLAG(flags, F_FOLLOWLINKS))) { - *filelistp = newfile; - filecount++; - } else { - free(newfile->d_name); - free(newfile); - } - } - } - } - - closedir(cd); - - return filecount; -} - -#ifndef EXTERNAL_MD5 - -/* If EXTERNAL_MD5 is not defined, use L. Peter Deutsch's MD5 library. - */ -char *getcrcsignatureuntil(char *filename, off_t max_read) -{ - int x; - off_t fsize; - off_t toread; - md5_state_t state; - md5_byte_t digest[16]; - static md5_byte_t chunk[CHUNK_SIZE]; - static char signature[16*2 + 1]; - char *sigp; - FILE *file; - - md5_init(&state); - - - fsize = filesize(filename); - - if (max_read != 0 && fsize > max_read) - fsize = max_read; - - file = fopen(filename, "rb"); - if (file == NULL) { - errormsg("error opening file %s\n", filename); - return NULL; - } - - while (fsize > 0) { - toread = (fsize % CHUNK_SIZE) ? (fsize % CHUNK_SIZE) : CHUNK_SIZE; - if (fread(chunk, toread, 1, file) != 1) { - errormsg("error reading from file %s\n", filename); - fclose(file); // bugfix - return NULL; - } - md5_append(&state, chunk, toread); - fsize -= toread; - } - - md5_finish(&state, digest); - - sigp = signature; - - for (x = 0; x < 16; x++) { - sprintf(sigp, "%02x", digest[x]); - sigp = strchr(sigp, '\0'); - } - - fclose(file); - - return signature; -} - -char *getcrcsignature(char *filename) -{ - return getcrcsignatureuntil(filename, 0); -} - -char *getcrcpartialsignature(char *filename) -{ - return getcrcsignatureuntil(filename, PARTIAL_MD5_SIZE); -} - -#endif /* [#ifndef EXTERNAL_MD5] */ - -#ifdef EXTERNAL_MD5 - -/* If EXTERNAL_MD5 is defined, use md5sum program to calculate signatures. - */ -char *getcrcsignature(char *filename) -{ - static char signature[256]; - char *command; - char *separator; - FILE *result; - - command = (char*) malloc(strlen(filename)+strlen(EXTERNAL_MD5)+2); - if (command == NULL) { - errormsg("out of memory\n"); - exit(1); - } - - sprintf(command, "%s %s", EXTERNAL_MD5, filename); - - result = popen(command, "r"); - if (result == NULL) { - errormsg("error invoking %s\n", EXTERNAL_MD5); - exit(1); - } - - free(command); - - if (fgets(signature, 256, result) == NULL) { - errormsg("error generating signature for %s\n", filename); - return NULL; - } - separator = strchr(signature, ' '); - if (separator) *separator = '\0'; - - pclose(result); - - return signature; -} - -#endif /* [#ifdef EXTERNAL_MD5] */ - -void purgetree(filetree_t *checktree) -{ - if (checktree->left != NULL) purgetree(checktree->left); - - if (checktree->right != NULL) purgetree(checktree->right); - - free(checktree); -} - -void getfilestats(file_t *file) -{ - file->size = filesize(file->d_name); - file->inode = getinode(file->d_name); - file->device = getdevice(file->d_name); - file->mtime = getmtime(file->d_name); -} - -int registerfile(filetree_t **branch, file_t *file) -{ - getfilestats(file); - - *branch = (filetree_t*) malloc(sizeof(filetree_t)); - if (*branch == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - - (*branch)->file = file; - (*branch)->left = NULL; - (*branch)->right = NULL; - - return 1; -} - -file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file) -{ - int cmpresult; - char *crcsignature; - off_t fsize; - - /* If device and inode fields are equal one of the files is a - hard link to the other or the files have been listed twice - unintentionally. We don't want to flag these files as - duplicates unless the user specifies otherwise. - */ - - if (!ISFLAG(flags, F_CONSIDERHARDLINKS) && (getinode(file->d_name) == - checktree->file->inode) && (getdevice(file->d_name) == - checktree->file->device)) return NULL; - - fsize = filesize(file->d_name); - - if (fsize < checktree->file->size) - cmpresult = -1; - else - if (fsize > checktree->file->size) cmpresult = 1; - else { - if (checktree->file->crcpartial == NULL) { - crcsignature = getcrcpartialsignature(checktree->file->d_name); - if (crcsignature == NULL) return NULL; - - checktree->file->crcpartial = (char*) malloc(strlen(crcsignature)+1); - if (checktree->file->crcpartial == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(checktree->file->crcpartial, crcsignature); - } - - if (file->crcpartial == NULL) { - crcsignature = getcrcpartialsignature(file->d_name); - if (crcsignature == NULL) return NULL; - - file->crcpartial = (char*) malloc(strlen(crcsignature)+1); - if (file->crcpartial == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(file->crcpartial, crcsignature); - } - - cmpresult = strcmp(file->crcpartial, checktree->file->crcpartial); - //if (cmpresult != 0) errormsg(" on %s vs %s\n", file->d_name, checktree->file->d_name); - - if (cmpresult == 0) { - if (checktree->file->crcsignature == NULL) { - crcsignature = getcrcsignature(checktree->file->d_name); - if (crcsignature == NULL) return NULL; - - checktree->file->crcsignature = (char*) malloc(strlen(crcsignature)+1); - if (checktree->file->crcsignature == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(checktree->file->crcsignature, crcsignature); - } - - if (file->crcsignature == NULL) { - crcsignature = getcrcsignature(file->d_name); - if (crcsignature == NULL) return NULL; - - file->crcsignature = (char*) malloc(strlen(crcsignature)+1); - if (file->crcsignature == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(file->crcsignature, crcsignature); - } - - cmpresult = strcmp(file->crcsignature, checktree->file->crcsignature); - //if (cmpresult != 0) errormsg("P on %s vs %s\n", - //file->d_name, checktree->file->d_name); - //else errormsg("P F on %s vs %s\n", file->d_name, - //checktree->file->d_name); - //printf("%s matches %s\n", file->d_name, checktree->file->d_name); - } - } - - if (cmpresult < 0) { - if (checktree->left != NULL) { - return checkmatch(root, checktree->left, file); - } else { - registerfile(&(checktree->left), file); - return NULL; - } - } else if (cmpresult > 0) { - if (checktree->right != NULL) { - return checkmatch(root, checktree->right, file); - } else { - registerfile(&(checktree->right), file); - return NULL; - } - } else - { - getfilestats(file); - return &checktree->file; - } -} - -/* Do a bit-for-bit comparison in case two different files produce the - same signature. Unlikely, but better safe than sorry. */ - -int confirmmatch(FILE *file1, FILE *file2) -{ - unsigned char c1 = 0; - unsigned char c2 = 0; - size_t r1; - size_t r2; - - fseek(file1, 0, SEEK_SET); - fseek(file2, 0, SEEK_SET); - - do { - r1 = fread(&c1, sizeof(c1), 1, file1); - r2 = fread(&c2, sizeof(c2), 1, file2); - - if (c1 != c2) return 0; /* file contents are different */ - } while (r1 && r2); - - if (r1 != r2) return 0; /* file lengths are different */ - - return 1; -} - -void summarizematches(file_t *files) -{ - int numsets = 0; - double numbytes = 0.0; - int numfiles = 0; - file_t *tmpfile; - - while (files != NULL) - { - if (files->hasdupes) - { - numsets++; - - tmpfile = files->duplicates; - while (tmpfile != NULL) - { - numfiles++; - numbytes += files->size; - tmpfile = tmpfile->duplicates; - } - } - - files = files->next; - } - - if (numsets == 0) - printf("No duplicates found.\n\n"); - else - { - if (numbytes < 1024.0) - printf("%d duplicate files (in %d sets), occupying %.0f bytes.\n\n", numfiles, numsets, numbytes); - else if (numbytes <= (1000.0 * 1000.0)) - printf("%d duplicate files (in %d sets), occupying %.1f kylobytes\n\n", numfiles, numsets, numbytes / 1000.0); - else - printf("%d duplicate files (in %d sets), occupying %.1f megabytes\n\n", numfiles, numsets, numbytes / (1000.0 * 1000.0)); - - } -} - -void printmatches(file_t *files) -{ - file_t *tmpfile; - - while (files != NULL) { - if (files->hasdupes) { - if (!ISFLAG(flags, F_OMITFIRST)) { - if (ISFLAG(flags, F_SHOWSIZE)) printf("%ld byte%seach:\n", files->size, - (files->size != 1) ? "s " : " "); - if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &files->d_name); - printf("%s%c", files->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n'); - } - tmpfile = files->duplicates; - while (tmpfile != NULL) { - if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &tmpfile->d_name); - printf("%s%c", tmpfile->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n'); - tmpfile = tmpfile->duplicates; - } - printf("\n"); - - } - - files = files->next; - } -} - -/* -#define REVISE_APPEND "_tmp" -char *revisefilename(char *path, int seq) -{ - int digits; - char *newpath; - char *scratch; - char *dot; - - digits = numdigits(seq); - newpath = malloc(strlen(path) + strlen(REVISE_APPEND) + digits + 1); - if (!newpath) return newpath; - - scratch = malloc(strlen(path) + 1); - if (!scratch) return newpath; - - strcpy(scratch, path); - dot = strrchr(scratch, '.'); - if (dot) - { - *dot = 0; - sprintf(newpath, "%s%s%d.%s", scratch, REVISE_APPEND, seq, dot + 1); - } - - else - { - sprintf(newpath, "%s%s%d", path, REVISE_APPEND, seq); - } - - free(scratch); - - return newpath; -} */ - -int relink(char *oldfile, char *newfile) -{ - dev_t od; - dev_t nd; - ino_t oi; - ino_t ni; - - od = getdevice(oldfile); - oi = getinode(oldfile); - - if (link(oldfile, newfile) != 0) - return 0; - - // make sure we're working with the right file (the one we created) - nd = getdevice(newfile); - ni = getinode(newfile); - - if (nd != od || oi != ni) - return 0; // file is not what we expected - - return 1; -} - -void deletefiles(file_t *files, int prompt) -{ - int counter; - int groups = 0; - int curgroup = 0; - file_t *tmpfile; - file_t *curfile; - file_t **dupelist; - int *preserve; - char *preservestr; - char *token; - char *tstr; - int number; - int sum; - int max = 0; - int x; - int i; - - curfile = files; - - while (curfile) { - if (curfile->hasdupes) { - counter = 1; - groups++; - - tmpfile = curfile->duplicates; - while (tmpfile) { - counter++; - tmpfile = tmpfile->duplicates; - } - - if (counter > max) max = counter; - } - - curfile = curfile->next; - } - - max++; - - dupelist = (file_t**) malloc(sizeof(file_t*) * max); - preserve = (int*) malloc(sizeof(int) * max); - preservestr = (char*) malloc(INPUT_SIZE); - - if (!dupelist || !preserve || !preservestr) { - errormsg("out of memory\n"); - exit(1); - } - - while (files) { - if (files->hasdupes) { - curgroup++; - counter = 1; - dupelist[counter] = files; - - if (prompt) printf("[%d] %s\n", counter, files->d_name); - - tmpfile = files->duplicates; - - while (tmpfile) { - dupelist[++counter] = tmpfile; - if (prompt) printf("[%d] %s\n", counter, tmpfile->d_name); - tmpfile = tmpfile->duplicates; - } - - if (prompt) printf("\n"); - - if (!prompt) /* preserve only the first file */ - { - preserve[1] = 1; - for (x = 2; x <= counter; x++) preserve[x] = 0; - } - - else /* prompt for files to preserve */ - - do { - printf("Set %d of %d, preserve files [1 - %d, all]", - curgroup, groups, counter); - if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%ld byte%seach)", files->size, - (files->size != 1) ? "s " : " "); - printf(": "); - fflush(stdout); - - fgets(preservestr, INPUT_SIZE, stdin); - - i = strlen(preservestr) - 1; - - while (preservestr[i]!='\n'){ /* tail of buffer must be a newline */ - tstr = (char*) - realloc(preservestr, strlen(preservestr) + 1 + INPUT_SIZE); - if (!tstr) { /* couldn't allocate memory, treat as fatal */ - errormsg("out of memory!\n"); - exit(1); - } - - preservestr = tstr; - if (!fgets(preservestr + i + 1, INPUT_SIZE, stdin)) - break; /* stop if fgets fails -- possible EOF? */ - i = strlen(preservestr)-1; - } - - for (x = 1; x <= counter; x++) preserve[x] = 0; - - token = strtok(preservestr, " ,\n"); - - while (token != NULL) { - if (strcasecmp(token, "all") == 0) - for (x = 0; x <= counter; x++) preserve[x] = 1; - - number = 0; - sscanf(token, "%d", &number); - if (number > 0 && number <= counter) preserve[number] = 1; - - token = strtok(NULL, " ,\n"); - } - - for (sum = 0, x = 1; x <= counter; x++) sum += preserve[x]; - } while (sum < 1); /* make sure we've preserved at least one file */ - - printf("\n"); - - for (x = 1; x <= counter; x++) { - if (preserve[x]) - printf(" [+] %s\n", dupelist[x]->d_name); - else { - if (remove(dupelist[x]->d_name) == 0) { - printf(" [-] %s\n", dupelist[x]->d_name); - } else { - printf(" [!] %s ", dupelist[x]->d_name); - printf("-- unable to delete file!\n"); - } - } - } - printf("\n"); - } - - files = files->next; - } - - free(dupelist); - free(preserve); - free(preservestr); -} - -int sort_pairs_by_arrival(file_t *f1, file_t *f2) -{ - if (f2->duplicates != 0) - return 1; - - return -1; -} - -int sort_pairs_by_mtime(file_t *f1, file_t *f2) -{ - if (f1->mtime < f2->mtime) - return -1; - else if (f1->mtime > f2->mtime) - return 1; - - //return sort_pairs_by_arrival(f1, f2); - return 0; -} - -void registerpair(file_t **matchlist, file_t *newmatch, - int (*comparef)(file_t *f1, file_t *f2)) -{ - file_t *traverse; - file_t *back; - - (*matchlist)->hasdupes = 1; - - back = 0; - traverse = *matchlist; - while (traverse) - { - if (comparef(newmatch, traverse) <= 0) - { - newmatch->duplicates = traverse; - - if (back == 0) - { - *matchlist = newmatch; // update pointer to head of list - - newmatch->hasdupes = 1; - traverse->hasdupes = 0; // flag is only for first file in dupe chain - } - else - back->duplicates = newmatch; - - break; - } - else - { - if (traverse->duplicates == 0) - { - traverse->duplicates = newmatch; - - if (back == 0) - traverse->hasdupes = 1; - - break; - } - } - - back = traverse; - traverse = traverse->duplicates; - } -} - -void help_text() -{ - printf("Usage: fdupes [options] DIRECTORY...\n\n"); - - printf(" -r --recurse \tfor every directory given follow subdirectories\n"); - printf(" \tencountered within\n"); - printf(" -R --recurse: \tfor each directory given after this option follow\n"); - printf(" \tsubdirectories encountered within\n"); - printf(" -s --symlinks \tfollow symlinks\n"); - printf(" -H --hardlinks \tnormally, when two or more files point to the same\n"); - printf(" \tdisk area they are treated as non-duplicates; this\n"); - printf(" \toption will change this behavior\n"); - printf(" -n --noempty \texclude zero-length files from consideration\n"); - printf(" -f --omitfirst \tomit the first file in each set of matches\n"); - printf(" -1 --sameline \tlist each set of matches on a single line\n"); - printf(" -S --size \tshow size of duplicate files\n"); - printf(" -m --summarize \tsummarize dupe information\n"); - printf(" -q --quiet \thide progress indicator\n"); - printf(" -d --delete \tprompt user for files to preserve and delete all\n"); - printf(" \tothers; important: under particular circumstances,\n"); - printf(" \tdata may be lost when using this option together\n"); - printf(" \twith -s or --symlinks, or when specifying a\n"); - printf(" \tparticular directory more than once; refer to the\n"); - printf(" \tfdupes documentation for additional information\n"); - //printf(" -l --relink \t(description)\n"); - printf(" -N --noprompt \ttogether with --delete, preserve the first file in\n"); - printf(" \teach set of duplicates and delete the rest without\n"); - printf(" \twithout prompting the user\n"); - printf(" -v --version \tdisplay fdupes version\n"); - printf(" -h --help \tdisplay this help message\n\n"); -#ifdef OMIT_GETOPT_LONG - printf("Note: Long options are not supported in this fdupes build.\n\n"); -#endif -} - -int main(int argc, char **argv) { - int x; - int opt; - FILE *file1; - FILE *file2; - file_t *files = NULL; - file_t *curfile; - file_t **match = NULL; - filetree_t *checktree = NULL; - int filecount = 0; - int progress = 0; - char **oldargv; - int firstrecurse; - -#ifndef OMIT_GETOPT_LONG - static struct option long_options[] = - { - { "omitfirst", 0, 0, 'f' }, - { "recurse", 0, 0, 'r' }, - { "recursive", 0, 0, 'r' }, - { "recurse:", 0, 0, 'R' }, - { "recursive:", 0, 0, 'R' }, - { "quiet", 0, 0, 'q' }, - { "sameline", 0, 0, '1' }, - { "size", 0, 0, 'S' }, - { "symlinks", 0, 0, 's' }, - { "hardlinks", 0, 0, 'H' }, - { "relink", 0, 0, 'l' }, - { "noempty", 0, 0, 'n' }, - { "delete", 0, 0, 'd' }, - { "version", 0, 0, 'v' }, - { "help", 0, 0, 'h' }, - { "noprompt", 0, 0, 'N' }, - { "summarize", 0, 0, 'm'}, - { "summary", 0, 0, 'm' }, - { 0, 0, 0, 0 } - }; -#define GETOPT getopt_long -#else -#define GETOPT getopt -#endif - - program_name = argv[0]; - - oldargv = cloneargs(argc, argv); - - while ((opt = GETOPT(argc, argv, "frRq1Ss::HlndvhNm" -#ifndef OMIT_GETOPT_LONG - , long_options, NULL -#endif - )) != EOF) { - switch (opt) { - case 'f': - SETFLAG(flags, F_OMITFIRST); - break; - case 'r': - SETFLAG(flags, F_RECURSE); - break; - case 'R': - SETFLAG(flags, F_RECURSEAFTER); - break; - case 'q': - SETFLAG(flags, F_HIDEPROGRESS); - break; - case '1': - SETFLAG(flags, F_DSAMELINE); - break; - case 'S': - SETFLAG(flags, F_SHOWSIZE); - break; - case 's': - SETFLAG(flags, F_FOLLOWLINKS); - break; - case 'H': - SETFLAG(flags, F_CONSIDERHARDLINKS); - break; - case 'n': - SETFLAG(flags, F_EXCLUDEEMPTY); - break; - case 'd': - SETFLAG(flags, F_DELETEFILES); - break; - case 'v': - printf("fdupes %s\n", VERSION); - exit(0); - case 'h': - help_text(); - exit(1); - case 'N': - SETFLAG(flags, F_NOPROMPT); - break; - case 'm': - SETFLAG(flags, F_SUMMARIZEMATCHES); - break; - - default: - fprintf(stderr, "Try `fdupes --help' for more information.\n"); - exit(1); - } - } - - if (optind >= argc) { - errormsg("no directories specified\n"); - exit(1); - } - - if (ISFLAG(flags, F_RECURSE) && ISFLAG(flags, F_RECURSEAFTER)) { - errormsg("options --recurse and --recurse: are not compatible\n"); - exit(1); - } - - if (ISFLAG(flags, F_SUMMARIZEMATCHES) && ISFLAG(flags, F_DELETEFILES)) { - errormsg("options --summarize and --delete are not compatible\n"); - exit(1); - } - - if (ISFLAG(flags, F_RECURSEAFTER)) { - firstrecurse = nonoptafter("--recurse:", argc, oldargv, argv, optind); - - if (firstrecurse == argc) - firstrecurse = nonoptafter("-R", argc, oldargv, argv, optind); - - if (firstrecurse == argc) { - errormsg("-R option must be isolated from other options\n"); - exit(1); - } - - /* F_RECURSE is not set for directories before --recurse: */ - for (x = optind; x < firstrecurse; x++) - filecount += grokdir(argv[x], &files); - - /* Set F_RECURSE for directories after --recurse: */ - SETFLAG(flags, F_RECURSE); - - for (x = firstrecurse; x < argc; x++) - filecount += grokdir(argv[x], &files); - } else { - for (x = optind; x < argc; x++) - filecount += grokdir(argv[x], &files); - } - - if (!files) { - if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " "); - exit(0); - } - - curfile = files; - - while (curfile) { - if (!checktree) - registerfile(&checktree, curfile); - else - match = checkmatch(&checktree, checktree, curfile); - - if (match != NULL) { - file1 = fopen(curfile->d_name, "rb"); - if (!file1) { - curfile = curfile->next; - continue; - } - - file2 = fopen((*match)->d_name, "rb"); - if (!file2) { - fclose(file1); - curfile = curfile->next; - continue; - } - - if (confirmmatch(file1, file2)) { - registerpair(match, curfile, sort_pairs_by_mtime); - - //match->hasdupes = 1; - //curfile->duplicates = match->duplicates; - //match->duplicates = curfile; - } - - fclose(file1); - fclose(file2); - } - - curfile = curfile->next; - - if (!ISFLAG(flags, F_HIDEPROGRESS)) { - fprintf(stderr, "\rProgress [%d/%d] %d%% ", progress, filecount, - (int)((float) progress / (float) filecount * 100.0)); - progress++; - } - } - - if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " "); - - if (ISFLAG(flags, F_DELETEFILES)) - { - if (ISFLAG(flags, F_NOPROMPT)) - deletefiles(files, 0); - else - deletefiles(files, 1); - } - - else - - if (ISFLAG(flags, F_SUMMARIZEMATCHES)) - summarizematches(files); - - else - - printmatches(files); - - while (files) { - curfile = files->next; - free(files->d_name); - free(files->crcsignature); - free(files->crcpartial); - free(files); - files = curfile; - } - - for (x = 0; x < argc; x++) - free(oldargv[x]); - - free(oldargv); - - purgetree(checktree); - - return 0; -} diff -Nru fdupes-1.51/.svn/pristine/1d/1d9f71f8c1e8ae30a626dee15c17c8061285e32d.svn-base fdupes-1.6.1/.svn/pristine/1d/1d9f71f8c1e8ae30a626dee15c17c8061285e32d.svn-base --- fdupes-1.51/.svn/pristine/1d/1d9f71f8c1e8ae30a626dee15c17c8061285e32d.svn-base 2013-04-20 18:05:48.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/1d/1d9f71f8c1e8ae30a626dee15c17c8061285e32d.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1198 +0,0 @@ -/* FDUPES Copyright (c) 1999-2002 Adrian Lopez - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include -#include -#include -#include -#include -#include -#include -#ifndef OMIT_GETOPT_LONG -#include -#endif -#include -#include - -#ifndef EXTERNAL_MD5 -#include "md5/md5.h" -#endif - -#define ISFLAG(a,b) ((a & b) == b) -#define SETFLAG(a,b) (a |= b) - -#define F_RECURSE 0x0001 -#define F_HIDEPROGRESS 0x0002 -#define F_DSAMELINE 0x0004 -#define F_FOLLOWLINKS 0x0008 -#define F_DELETEFILES 0x0010 -#define F_EXCLUDEEMPTY 0x0020 -#define F_CONSIDERHARDLINKS 0x0040 -#define F_SHOWSIZE 0x0080 -#define F_OMITFIRST 0x0100 -#define F_RECURSEAFTER 0x0200 -#define F_NOPROMPT 0x0400 -#define F_SUMMARIZEMATCHES 0x0800 - -char *program_name; - -unsigned long flags = 0; - -#define CHUNK_SIZE 8192 - -#define INPUT_SIZE 256 - -#define PARTIAL_MD5_SIZE 4096 - -/* - -TODO: Partial sums (for working with very large files). - -typedef struct _signature -{ - md5_state_t state; - md5_byte_t digest[16]; -} signature_t; - -typedef struct _signatures -{ - int num_signatures; - signature_t *signatures; -} signatures_t; - -*/ - -typedef struct _file { - char *d_name; - off_t size; - char *crcpartial; - char *crcsignature; - dev_t device; - ino_t inode; - time_t mtime; - int hasdupes; /* true only if file is first on duplicate chain */ - struct _file *duplicates; - struct _file *next; -} file_t; - -typedef struct _filetree { - file_t *file; - struct _filetree *left; - struct _filetree *right; -} filetree_t; - -void errormsg(char *message, ...) -{ - va_list ap; - - va_start(ap, message); - - fprintf(stderr, "\r%40s\r%s: ", "", program_name); - vfprintf(stderr, message, ap); -} - -void escapefilename(char *escape_list, char **filename_ptr) -{ - int x; - int tx; - char *tmp; - char *filename; - - filename = *filename_ptr; - - tmp = (char*) malloc(strlen(filename) * 2 + 1); - if (tmp == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - - for (x = 0, tx = 0; x < strlen(filename); x++) { - if (strchr(escape_list, filename[x]) != NULL) tmp[tx++] = '\\'; - tmp[tx++] = filename[x]; - } - - tmp[tx] = '\0'; - - if (x != tx) { - *filename_ptr = realloc(*filename_ptr, strlen(tmp) + 1); - if (*filename_ptr == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - strcpy(*filename_ptr, tmp); - } -} - -off_t filesize(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return -1; - - return s.st_size; -} - -dev_t getdevice(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return 0; - - return s.st_dev; -} - -ino_t getinode(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return 0; - - return s.st_ino; -} - -time_t getmtime(char *filename) { - struct stat s; - - if (stat(filename, &s) != 0) return 0; - - return s.st_mtime; -} - -char **cloneargs(int argc, char **argv) -{ - int x; - char **args; - - args = (char **) malloc(sizeof(char*) * argc); - if (args == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - - for (x = 0; x < argc; x++) { - args[x] = (char*) malloc(strlen(argv[x]) + 1); - if (args[x] == NULL) { - free(args); - errormsg("out of memory!\n"); - exit(1); - } - - strcpy(args[x], argv[x]); - } - - return args; -} - -int findarg(char *arg, int start, int argc, char **argv) -{ - int x; - - for (x = start; x < argc; x++) - if (strcmp(argv[x], arg) == 0) - return x; - - return x; -} - -/* Find the first non-option argument after specified option. */ -int nonoptafter(char *option, int argc, char **oldargv, - char **newargv, int optind) -{ - int x; - int targetind; - int testind; - int startat = 1; - - targetind = findarg(option, 1, argc, oldargv); - - for (x = optind; x < argc; x++) { - testind = findarg(newargv[x], startat, argc, oldargv); - if (testind > targetind) return x; - else startat = testind; - } - - return x; -} - -int grokdir(char *dir, file_t **filelistp) -{ - DIR *cd; - file_t *newfile; - struct dirent *dirinfo; - int lastchar; - int filecount = 0; - struct stat info; - struct stat linfo; - static int progress = 0; - static char indicator[] = "-\\|/"; - - cd = opendir(dir); - - if (!cd) { - errormsg("could not chdir to %s\n", dir); - return 0; - } - - while ((dirinfo = readdir(cd)) != NULL) { - if (strcmp(dirinfo->d_name, ".") && strcmp(dirinfo->d_name, "..")) { - if (!ISFLAG(flags, F_HIDEPROGRESS)) { - fprintf(stderr, "\rBuilding file list %c ", indicator[progress]); - progress = (progress + 1) % 4; - } - - newfile = (file_t*) malloc(sizeof(file_t)); - - if (!newfile) { - errormsg("out of memory!\n"); - closedir(cd); - exit(1); - } else newfile->next = *filelistp; - - newfile->device = 0; - newfile->inode = 0; - newfile->crcsignature = NULL; - newfile->crcpartial = NULL; - newfile->duplicates = NULL; - newfile->hasdupes = 0; - - newfile->d_name = (char*)malloc(strlen(dir)+strlen(dirinfo->d_name)+2); - - if (!newfile->d_name) { - errormsg("out of memory!\n"); - free(newfile); - closedir(cd); - exit(1); - } - - strcpy(newfile->d_name, dir); - lastchar = strlen(dir) - 1; - if (lastchar >= 0 && dir[lastchar] != '/') - strcat(newfile->d_name, "/"); - strcat(newfile->d_name, dirinfo->d_name); - - if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) { - free(newfile->d_name); - free(newfile); - continue; - } - - if (stat(newfile->d_name, &info) == -1) { - free(newfile->d_name); - free(newfile); - continue; - } - - if (lstat(newfile->d_name, &linfo) == -1) { - free(newfile->d_name); - free(newfile); - continue; - } - - if (S_ISDIR(info.st_mode)) { - if (ISFLAG(flags, F_RECURSE) && (ISFLAG(flags, F_FOLLOWLINKS) || !S_ISLNK(linfo.st_mode))) - filecount += grokdir(newfile->d_name, filelistp); - free(newfile->d_name); - free(newfile); - } else { - if (S_ISREG(linfo.st_mode) || (S_ISLNK(linfo.st_mode) && ISFLAG(flags, F_FOLLOWLINKS))) { - *filelistp = newfile; - filecount++; - } else { - free(newfile->d_name); - free(newfile); - } - } - } - } - - closedir(cd); - - return filecount; -} - -#ifndef EXTERNAL_MD5 - -/* If EXTERNAL_MD5 is not defined, use L. Peter Deutsch's MD5 library. - */ -char *getcrcsignatureuntil(char *filename, off_t max_read) -{ - int x; - off_t fsize; - off_t toread; - md5_state_t state; - md5_byte_t digest[16]; - static md5_byte_t chunk[CHUNK_SIZE]; - static char signature[16*2 + 1]; - char *sigp; - FILE *file; - - md5_init(&state); - - - fsize = filesize(filename); - - if (max_read != 0 && fsize > max_read) - fsize = max_read; - - file = fopen(filename, "rb"); - if (file == NULL) { - errormsg("error opening file %s\n", filename); - return NULL; - } - - while (fsize > 0) { - toread = (fsize % CHUNK_SIZE) ? (fsize % CHUNK_SIZE) : CHUNK_SIZE; - if (fread(chunk, toread, 1, file) != 1) { - errormsg("error reading from file %s\n", filename); - fclose(file); - return NULL; - } - md5_append(&state, chunk, toread); - fsize -= toread; - } - - md5_finish(&state, digest); - - sigp = signature; - - for (x = 0; x < 16; x++) { - sprintf(sigp, "%02x", digest[x]); - sigp = strchr(sigp, '\0'); - } - - fclose(file); - - return signature; -} - -char *getcrcsignature(char *filename) -{ - return getcrcsignatureuntil(filename, 0); -} - -char *getcrcpartialsignature(char *filename) -{ - return getcrcsignatureuntil(filename, PARTIAL_MD5_SIZE); -} - -#endif /* [#ifndef EXTERNAL_MD5] */ - -#ifdef EXTERNAL_MD5 - -/* If EXTERNAL_MD5 is defined, use md5sum program to calculate signatures. - */ -char *getcrcsignature(char *filename) -{ - static char signature[256]; - char *command; - char *separator; - FILE *result; - - command = (char*) malloc(strlen(filename)+strlen(EXTERNAL_MD5)+2); - if (command == NULL) { - errormsg("out of memory\n"); - exit(1); - } - - sprintf(command, "%s %s", EXTERNAL_MD5, filename); - - result = popen(command, "r"); - if (result == NULL) { - errormsg("error invoking %s\n", EXTERNAL_MD5); - exit(1); - } - - free(command); - - if (fgets(signature, 256, result) == NULL) { - errormsg("error generating signature for %s\n", filename); - return NULL; - } - separator = strchr(signature, ' '); - if (separator) *separator = '\0'; - - pclose(result); - - return signature; -} - -#endif /* [#ifdef EXTERNAL_MD5] */ - -void purgetree(filetree_t *checktree) -{ - if (checktree->left != NULL) purgetree(checktree->left); - - if (checktree->right != NULL) purgetree(checktree->right); - - free(checktree); -} - -void getfilestats(file_t *file) -{ - file->size = filesize(file->d_name); - file->inode = getinode(file->d_name); - file->device = getdevice(file->d_name); - file->mtime = getmtime(file->d_name); -} - -int registerfile(filetree_t **branch, file_t *file) -{ - getfilestats(file); - - *branch = (filetree_t*) malloc(sizeof(filetree_t)); - if (*branch == NULL) { - errormsg("out of memory!\n"); - exit(1); - } - - (*branch)->file = file; - (*branch)->left = NULL; - (*branch)->right = NULL; - - return 1; -} - -file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file) -{ - int cmpresult; - char *crcsignature; - off_t fsize; - - /* If device and inode fields are equal one of the files is a - hard link to the other or the files have been listed twice - unintentionally. We don't want to flag these files as - duplicates unless the user specifies otherwise. - */ - - if (!ISFLAG(flags, F_CONSIDERHARDLINKS) && (getinode(file->d_name) == - checktree->file->inode) && (getdevice(file->d_name) == - checktree->file->device)) return NULL; - - fsize = filesize(file->d_name); - - if (fsize < checktree->file->size) - cmpresult = -1; - else - if (fsize > checktree->file->size) cmpresult = 1; - else { - if (checktree->file->crcpartial == NULL) { - crcsignature = getcrcpartialsignature(checktree->file->d_name); - if (crcsignature == NULL) return NULL; - - checktree->file->crcpartial = (char*) malloc(strlen(crcsignature)+1); - if (checktree->file->crcpartial == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(checktree->file->crcpartial, crcsignature); - } - - if (file->crcpartial == NULL) { - crcsignature = getcrcpartialsignature(file->d_name); - if (crcsignature == NULL) return NULL; - - file->crcpartial = (char*) malloc(strlen(crcsignature)+1); - if (file->crcpartial == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(file->crcpartial, crcsignature); - } - - cmpresult = strcmp(file->crcpartial, checktree->file->crcpartial); - /*if (cmpresult != 0) errormsg(" on %s vs %s\n", file->d_name, checktree->file->d_name);*/ - - if (cmpresult == 0) { - if (checktree->file->crcsignature == NULL) { - crcsignature = getcrcsignature(checktree->file->d_name); - if (crcsignature == NULL) return NULL; - - checktree->file->crcsignature = (char*) malloc(strlen(crcsignature)+1); - if (checktree->file->crcsignature == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(checktree->file->crcsignature, crcsignature); - } - - if (file->crcsignature == NULL) { - crcsignature = getcrcsignature(file->d_name); - if (crcsignature == NULL) return NULL; - - file->crcsignature = (char*) malloc(strlen(crcsignature)+1); - if (file->crcsignature == NULL) { - errormsg("out of memory\n"); - exit(1); - } - strcpy(file->crcsignature, crcsignature); - } - - cmpresult = strcmp(file->crcsignature, checktree->file->crcsignature); - /*if (cmpresult != 0) errormsg("P on %s vs %s\n", - file->d_name, checktree->file->d_name); - else errormsg("P F on %s vs %s\n", file->d_name, - checktree->file->d_name); - printf("%s matches %s\n", file->d_name, checktree->file->d_name);*/ - } - } - - if (cmpresult < 0) { - if (checktree->left != NULL) { - return checkmatch(root, checktree->left, file); - } else { - registerfile(&(checktree->left), file); - return NULL; - } - } else if (cmpresult > 0) { - if (checktree->right != NULL) { - return checkmatch(root, checktree->right, file); - } else { - registerfile(&(checktree->right), file); - return NULL; - } - } else - { - getfilestats(file); - return &checktree->file; - } -} - -/* Do a bit-for-bit comparison in case two different files produce the - same signature. Unlikely, but better safe than sorry. */ - -int confirmmatch(FILE *file1, FILE *file2) -{ - unsigned char c1 = 0; - unsigned char c2 = 0; - size_t r1; - size_t r2; - - fseek(file1, 0, SEEK_SET); - fseek(file2, 0, SEEK_SET); - - do { - r1 = fread(&c1, sizeof(c1), 1, file1); - r2 = fread(&c2, sizeof(c2), 1, file2); - - if (c1 != c2) return 0; /* file contents are different */ - } while (r1 && r2); - - if (r1 != r2) return 0; /* file lengths are different */ - - return 1; -} - -void summarizematches(file_t *files) -{ - int numsets = 0; - double numbytes = 0.0; - int numfiles = 0; - file_t *tmpfile; - - while (files != NULL) - { - if (files->hasdupes) - { - numsets++; - - tmpfile = files->duplicates; - while (tmpfile != NULL) - { - numfiles++; - numbytes += files->size; - tmpfile = tmpfile->duplicates; - } - } - - files = files->next; - } - - if (numsets == 0) - printf("No duplicates found.\n\n"); - else - { - if (numbytes < 1024.0) - printf("%d duplicate files (in %d sets), occupying %.0f bytes.\n\n", numfiles, numsets, numbytes); - else if (numbytes <= (1000.0 * 1000.0)) - printf("%d duplicate files (in %d sets), occupying %.1f kylobytes\n\n", numfiles, numsets, numbytes / 1000.0); - else - printf("%d duplicate files (in %d sets), occupying %.1f megabytes\n\n", numfiles, numsets, numbytes / (1000.0 * 1000.0)); - - } -} - -void printmatches(file_t *files) -{ - file_t *tmpfile; - - while (files != NULL) { - if (files->hasdupes) { - if (!ISFLAG(flags, F_OMITFIRST)) { - if (ISFLAG(flags, F_SHOWSIZE)) printf("%lld byte%seach:\n", files->size, - (files->size != 1) ? "s " : " "); - if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &files->d_name); - printf("%s%c", files->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n'); - } - tmpfile = files->duplicates; - while (tmpfile != NULL) { - if (ISFLAG(flags, F_DSAMELINE)) escapefilename("\\ ", &tmpfile->d_name); - printf("%s%c", tmpfile->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n'); - tmpfile = tmpfile->duplicates; - } - printf("\n"); - - } - - files = files->next; - } -} - -/* -#define REVISE_APPEND "_tmp" -char *revisefilename(char *path, int seq) -{ - int digits; - char *newpath; - char *scratch; - char *dot; - - digits = numdigits(seq); - newpath = malloc(strlen(path) + strlen(REVISE_APPEND) + digits + 1); - if (!newpath) return newpath; - - scratch = malloc(strlen(path) + 1); - if (!scratch) return newpath; - - strcpy(scratch, path); - dot = strrchr(scratch, '.'); - if (dot) - { - *dot = 0; - sprintf(newpath, "%s%s%d.%s", scratch, REVISE_APPEND, seq, dot + 1); - } - - else - { - sprintf(newpath, "%s%s%d", path, REVISE_APPEND, seq); - } - - free(scratch); - - return newpath; -} */ - -int relink(char *oldfile, char *newfile) -{ - dev_t od; - dev_t nd; - ino_t oi; - ino_t ni; - - od = getdevice(oldfile); - oi = getinode(oldfile); - - if (link(oldfile, newfile) != 0) - return 0; - - /* make sure we're working with the right file (the one we created) */ - nd = getdevice(newfile); - ni = getinode(newfile); - - if (nd != od || oi != ni) - return 0; /* file is not what we expected */ - - return 1; -} - -void deletefiles(file_t *files, int prompt, FILE *tty) -{ - int counter; - int groups = 0; - int curgroup = 0; - file_t *tmpfile; - file_t *curfile; - file_t **dupelist; - int *preserve; - char *preservestr; - char *token; - char *tstr; - int number; - int sum; - int max = 0; - int x; - int i; - - curfile = files; - - while (curfile) { - if (curfile->hasdupes) { - counter = 1; - groups++; - - tmpfile = curfile->duplicates; - while (tmpfile) { - counter++; - tmpfile = tmpfile->duplicates; - } - - if (counter > max) max = counter; - } - - curfile = curfile->next; - } - - max++; - - dupelist = (file_t**) malloc(sizeof(file_t*) * max); - preserve = (int*) malloc(sizeof(int) * max); - preservestr = (char*) malloc(INPUT_SIZE); - - if (!dupelist || !preserve || !preservestr) { - errormsg("out of memory\n"); - exit(1); - } - - while (files) { - if (files->hasdupes) { - curgroup++; - counter = 1; - dupelist[counter] = files; - - if (prompt) printf("[%d] %s\n", counter, files->d_name); - - tmpfile = files->duplicates; - - while (tmpfile) { - dupelist[++counter] = tmpfile; - if (prompt) printf("[%d] %s\n", counter, tmpfile->d_name); - tmpfile = tmpfile->duplicates; - } - - if (prompt) printf("\n"); - - if (!prompt) /* preserve only the first file */ - { - preserve[1] = 1; - for (x = 2; x <= counter; x++) preserve[x] = 0; - } - - else /* prompt for files to preserve */ - - do { - printf("Set %d of %d, preserve files [1 - %d, all]", - curgroup, groups, counter); - if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%lld byte%seach)", files->size, - (files->size != 1) ? "s " : " "); - printf(": "); - fflush(stdout); - - if (!fgets(preservestr, INPUT_SIZE, tty)) - preservestr[0] = '\n'; /* treat fgets() failure as if nothing was entered */ - - i = strlen(preservestr) - 1; - - while (preservestr[i]!='\n'){ /* tail of buffer must be a newline */ - tstr = (char*) - realloc(preservestr, strlen(preservestr) + 1 + INPUT_SIZE); - if (!tstr) { /* couldn't allocate memory, treat as fatal */ - errormsg("out of memory!\n"); - exit(1); - } - - preservestr = tstr; - if (!fgets(preservestr + i + 1, INPUT_SIZE, tty)) - { - preservestr[0] = '\n'; /* treat fgets() failure as if nothing was entered */ - break; - } - i = strlen(preservestr)-1; - } - - for (x = 1; x <= counter; x++) preserve[x] = 0; - - token = strtok(preservestr, " ,\n"); - - while (token != NULL) { - if (strcasecmp(token, "all") == 0) - for (x = 0; x <= counter; x++) preserve[x] = 1; - - number = 0; - sscanf(token, "%d", &number); - if (number > 0 && number <= counter) preserve[number] = 1; - - token = strtok(NULL, " ,\n"); - } - - for (sum = 0, x = 1; x <= counter; x++) sum += preserve[x]; - } while (sum < 1); /* make sure we've preserved at least one file */ - - printf("\n"); - - for (x = 1; x <= counter; x++) { - if (preserve[x]) - printf(" [+] %s\n", dupelist[x]->d_name); - else { - if (remove(dupelist[x]->d_name) == 0) { - printf(" [-] %s\n", dupelist[x]->d_name); - } else { - printf(" [!] %s ", dupelist[x]->d_name); - printf("-- unable to delete file!\n"); - } - } - } - printf("\n"); - } - - files = files->next; - } - - free(dupelist); - free(preserve); - free(preservestr); -} - -int sort_pairs_by_arrival(file_t *f1, file_t *f2) -{ - if (f2->duplicates != 0) - return 1; - - return -1; -} - -int sort_pairs_by_mtime(file_t *f1, file_t *f2) -{ - if (f1->mtime < f2->mtime) - return -1; - else if (f1->mtime > f2->mtime) - return 1; - - return 0; -} - -void registerpair(file_t **matchlist, file_t *newmatch, - int (*comparef)(file_t *f1, file_t *f2)) -{ - file_t *traverse; - file_t *back; - - (*matchlist)->hasdupes = 1; - - back = 0; - traverse = *matchlist; - while (traverse) - { - if (comparef(newmatch, traverse) <= 0) - { - newmatch->duplicates = traverse; - - if (back == 0) - { - *matchlist = newmatch; /* update pointer to head of list */ - - newmatch->hasdupes = 1; - traverse->hasdupes = 0; /* flag is only for first file in dupe chain */ - } - else - back->duplicates = newmatch; - - break; - } - else - { - if (traverse->duplicates == 0) - { - traverse->duplicates = newmatch; - - if (back == 0) - traverse->hasdupes = 1; - - break; - } - } - - back = traverse; - traverse = traverse->duplicates; - } -} - -void help_text() -{ - printf("Usage: fdupes [options] DIRECTORY...\n\n"); - - printf(" -r --recurse \tfor every directory given follow subdirectories\n"); - printf(" \tencountered within\n"); - printf(" -R --recurse: \tfor each directory given after this option follow\n"); - printf(" \tsubdirectories encountered within\n"); - printf(" -s --symlinks \tfollow symlinks\n"); - printf(" -H --hardlinks \tnormally, when two or more files point to the same\n"); - printf(" \tdisk area they are treated as non-duplicates; this\n"); - printf(" \toption will change this behavior\n"); - printf(" -n --noempty \texclude zero-length files from consideration\n"); - printf(" -f --omitfirst \tomit the first file in each set of matches\n"); - printf(" -1 --sameline \tlist each set of matches on a single line\n"); - printf(" -S --size \tshow size of duplicate files\n"); - printf(" -m --summarize \tsummarize dupe information\n"); - printf(" -q --quiet \thide progress indicator\n"); - printf(" -d --delete \tprompt user for files to preserve and delete all\n"); - printf(" \tothers; important: under particular circumstances,\n"); - printf(" \tdata may be lost when using this option together\n"); - printf(" \twith -s or --symlinks, or when specifying a\n"); - printf(" \tparticular directory more than once; refer to the\n"); - printf(" \tfdupes documentation for additional information\n"); - /*printf(" -l --relink \t(description)\n");*/ - printf(" -N --noprompt \ttogether with --delete, preserve the first file in\n"); - printf(" \teach set of duplicates and delete the rest without\n"); - printf(" \tprompting the user\n"); - printf(" -v --version \tdisplay fdupes version\n"); - printf(" -h --help \tdisplay this help message\n\n"); -#ifdef OMIT_GETOPT_LONG - printf("Note: Long options are not supported in this fdupes build.\n\n"); -#endif -} - -int main(int argc, char **argv) { - int x; - int opt; - FILE *file1; - FILE *file2; - file_t *files = NULL; - file_t *curfile; - file_t **match = NULL; - filetree_t *checktree = NULL; - int filecount = 0; - int progress = 0; - char **oldargv; - int firstrecurse; - -#ifndef OMIT_GETOPT_LONG - static struct option long_options[] = - { - { "omitfirst", 0, 0, 'f' }, - { "recurse", 0, 0, 'r' }, - { "recursive", 0, 0, 'r' }, - { "recurse:", 0, 0, 'R' }, - { "recursive:", 0, 0, 'R' }, - { "quiet", 0, 0, 'q' }, - { "sameline", 0, 0, '1' }, - { "size", 0, 0, 'S' }, - { "symlinks", 0, 0, 's' }, - { "hardlinks", 0, 0, 'H' }, - { "relink", 0, 0, 'l' }, - { "noempty", 0, 0, 'n' }, - { "delete", 0, 0, 'd' }, - { "version", 0, 0, 'v' }, - { "help", 0, 0, 'h' }, - { "noprompt", 0, 0, 'N' }, - { "summarize", 0, 0, 'm'}, - { "summary", 0, 0, 'm' }, - { 0, 0, 0, 0 } - }; -#define GETOPT getopt_long -#else -#define GETOPT getopt -#endif - - program_name = argv[0]; - - oldargv = cloneargs(argc, argv); - - while ((opt = GETOPT(argc, argv, "frRq1Ss::HlndvhNm" -#ifndef OMIT_GETOPT_LONG - , long_options, NULL -#endif - )) != EOF) { - switch (opt) { - case 'f': - SETFLAG(flags, F_OMITFIRST); - break; - case 'r': - SETFLAG(flags, F_RECURSE); - break; - case 'R': - SETFLAG(flags, F_RECURSEAFTER); - break; - case 'q': - SETFLAG(flags, F_HIDEPROGRESS); - break; - case '1': - SETFLAG(flags, F_DSAMELINE); - break; - case 'S': - SETFLAG(flags, F_SHOWSIZE); - break; - case 's': - SETFLAG(flags, F_FOLLOWLINKS); - break; - case 'H': - SETFLAG(flags, F_CONSIDERHARDLINKS); - break; - case 'n': - SETFLAG(flags, F_EXCLUDEEMPTY); - break; - case 'd': - SETFLAG(flags, F_DELETEFILES); - break; - case 'v': - printf("fdupes %s\n", VERSION); - exit(0); - case 'h': - help_text(); - exit(1); - case 'N': - SETFLAG(flags, F_NOPROMPT); - break; - case 'm': - SETFLAG(flags, F_SUMMARIZEMATCHES); - break; - - default: - fprintf(stderr, "Try `fdupes --help' for more information.\n"); - exit(1); - } - } - - if (optind >= argc) { - errormsg("no directories specified\n"); - exit(1); - } - - if (ISFLAG(flags, F_RECURSE) && ISFLAG(flags, F_RECURSEAFTER)) { - errormsg("options --recurse and --recurse: are not compatible\n"); - exit(1); - } - - if (ISFLAG(flags, F_SUMMARIZEMATCHES) && ISFLAG(flags, F_DELETEFILES)) { - errormsg("options --summarize and --delete are not compatible\n"); - exit(1); - } - - if (ISFLAG(flags, F_RECURSEAFTER)) { - firstrecurse = nonoptafter("--recurse:", argc, oldargv, argv, optind); - - if (firstrecurse == argc) - firstrecurse = nonoptafter("-R", argc, oldargv, argv, optind); - - if (firstrecurse == argc) { - errormsg("-R option must be isolated from other options\n"); - exit(1); - } - - /* F_RECURSE is not set for directories before --recurse: */ - for (x = optind; x < firstrecurse; x++) - filecount += grokdir(argv[x], &files); - - /* Set F_RECURSE for directories after --recurse: */ - SETFLAG(flags, F_RECURSE); - - for (x = firstrecurse; x < argc; x++) - filecount += grokdir(argv[x], &files); - } else { - for (x = optind; x < argc; x++) - filecount += grokdir(argv[x], &files); - } - - if (!files) { - if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " "); - exit(0); - } - - curfile = files; - - while (curfile) { - if (!checktree) - registerfile(&checktree, curfile); - else - match = checkmatch(&checktree, checktree, curfile); - - if (match != NULL) { - file1 = fopen(curfile->d_name, "rb"); - if (!file1) { - curfile = curfile->next; - continue; - } - - file2 = fopen((*match)->d_name, "rb"); - if (!file2) { - fclose(file1); - curfile = curfile->next; - continue; - } - - if (confirmmatch(file1, file2)) { - registerpair(match, curfile, sort_pairs_by_mtime); - - /*match->hasdupes = 1; - curfile->duplicates = match->duplicates; - match->duplicates = curfile;*/ - } - - fclose(file1); - fclose(file2); - } - - curfile = curfile->next; - - if (!ISFLAG(flags, F_HIDEPROGRESS)) { - fprintf(stderr, "\rProgress [%d/%d] %d%% ", progress, filecount, - (int)((float) progress / (float) filecount * 100.0)); - progress++; - } - } - - if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " "); - - if (ISFLAG(flags, F_DELETEFILES)) - { - if (ISFLAG(flags, F_NOPROMPT)) - { - deletefiles(files, 0, 0); - } - else - { - stdin = freopen("/dev/tty", "r", stdin); - deletefiles(files, 1, stdin); - } - } - - else - - if (ISFLAG(flags, F_SUMMARIZEMATCHES)) - summarizematches(files); - - else - - printmatches(files); - - while (files) { - curfile = files->next; - free(files->d_name); - free(files->crcsignature); - free(files->crcpartial); - free(files); - files = curfile; - } - - for (x = 0; x < argc; x++) - free(oldargv[x]); - - free(oldargv); - - purgetree(checktree); - - return 0; -} diff -Nru fdupes-1.51/.svn/pristine/1e/1e7720a3460b8a84ac4ba27880d64526a3872f1c.svn-base fdupes-1.6.1/.svn/pristine/1e/1e7720a3460b8a84ac4ba27880d64526a3872f1c.svn-base --- fdupes-1.51/.svn/pristine/1e/1e7720a3460b8a84ac4ba27880d64526a3872f1c.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/1e/1e7720a3460b8a84ac4ba27880d64526a3872f1c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -three diff -Nru fdupes-1.51/.svn/pristine/2f/2f93a711e65db83f78c6cbccb255c8375b440223.svn-base fdupes-1.6.1/.svn/pristine/2f/2f93a711e65db83f78c6cbccb255c8375b440223.svn-base --- fdupes-1.51/.svn/pristine/2f/2f93a711e65db83f78c6cbccb255c8375b440223.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/2f/2f93a711e65db83f78c6cbccb255c8375b440223.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,396 +0,0 @@ -/* - Copyright (C) 1999 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost@aladdin.com - - */ -/*$Id: md5.c $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321. - It is derived directly from the text of the RFC and not from the - reference implementation. - - The original and principal author of md5.c is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - contributors - chl - Charles Longeau - - 2002-05-31 chl Relocated string.h to avoid memcpy warning. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). - 1999-05-03 lpd Original version. - */ - -#include "md5.h" -#include - -#ifdef TEST -/* - * Compile with -DTEST to create a self-contained executable test program. - * The test program should print out the same values as given in section - * A.5 of RFC 1321, reproduced below. - */ -main() -{ - static const char *const test[7] = { - "", /*d41d8cd98f00b204e9800998ecf8427e*/ - "a", /*0cc175b9c0f1b6a831c399e269772661*/ - "abc", /*900150983cd24fb0d6963f7d28e17f72*/ - "message digest", /*f96b697d7cb7938d525a2f31aaf161d0*/ - "abcdefghijklmnopqrstuvwxyz", /*c3fcd3d76192e4007dfb496cca67e13b*/ - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - /*d174ab98d277d9f5a5611c2c9f419d9f*/ - "12345678901234567890123456789012345678901234567890123456789012345678901234567890" /*57edf4a22be3c955ac49da2e2107b67a*/ - }; - int i; - - for (i = 0; i < 7; ++i) { - md5_state_t state; - md5_byte_t digest[16]; - int di; - - md5_init(&state); - md5_append(&state, (const md5_byte_t *)test[i], strlen(test[i])); - md5_finish(&state, digest); - printf("MD5 (\"%s\") = ", test[i]); - for (di = 0; di < 16; ++di) - printf("%02x", digest[di]); - printf("\n"); - } - return 0; -} -#endif /* TEST */ - - -/* - * For reference, here is the program that computed the T values. - */ -#if 0 -#include -main() -{ - int i; - for (i = 1; i <= 64; ++i) { - unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i))); - printf("#define T%d 0x%08lx\n", i, v); - } - return 0; -} -#endif -/* - * End of T computation program. - */ -#define T1 0xd76aa478 -#define T2 0xe8c7b756 -#define T3 0x242070db -#define T4 0xc1bdceee -#define T5 0xf57c0faf -#define T6 0x4787c62a -#define T7 0xa8304613 -#define T8 0xfd469501 -#define T9 0x698098d8 -#define T10 0x8b44f7af -#define T11 0xffff5bb1 -#define T12 0x895cd7be -#define T13 0x6b901122 -#define T14 0xfd987193 -#define T15 0xa679438e -#define T16 0x49b40821 -#define T17 0xf61e2562 -#define T18 0xc040b340 -#define T19 0x265e5a51 -#define T20 0xe9b6c7aa -#define T21 0xd62f105d -#define T22 0x02441453 -#define T23 0xd8a1e681 -#define T24 0xe7d3fbc8 -#define T25 0x21e1cde6 -#define T26 0xc33707d6 -#define T27 0xf4d50d87 -#define T28 0x455a14ed -#define T29 0xa9e3e905 -#define T30 0xfcefa3f8 -#define T31 0x676f02d9 -#define T32 0x8d2a4c8a -#define T33 0xfffa3942 -#define T34 0x8771f681 -#define T35 0x6d9d6122 -#define T36 0xfde5380c -#define T37 0xa4beea44 -#define T38 0x4bdecfa9 -#define T39 0xf6bb4b60 -#define T40 0xbebfbc70 -#define T41 0x289b7ec6 -#define T42 0xeaa127fa -#define T43 0xd4ef3085 -#define T44 0x04881d05 -#define T45 0xd9d4d039 -#define T46 0xe6db99e5 -#define T47 0x1fa27cf8 -#define T48 0xc4ac5665 -#define T49 0xf4292244 -#define T50 0x432aff97 -#define T51 0xab9423a7 -#define T52 0xfc93a039 -#define T53 0x655b59c3 -#define T54 0x8f0ccc92 -#define T55 0xffeff47d -#define T56 0x85845dd1 -#define T57 0x6fa87e4f -#define T58 0xfe2ce6e0 -#define T59 0xa3014314 -#define T60 0x4e0811a1 -#define T61 0xf7537e82 -#define T62 0xbd3af235 -#define T63 0x2ad7d2bb -#define T64 0xeb86d391 - -static void -md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) -{ - md5_word_t - a = pms->abcd[0], b = pms->abcd[1], - c = pms->abcd[2], d = pms->abcd[3]; - md5_word_t t; - -#ifndef ARCH_IS_BIG_ENDIAN -# define ARCH_IS_BIG_ENDIAN 1 /* slower, default implementation */ -#endif -#if ARCH_IS_BIG_ENDIAN - - /* - * On big-endian machines, we must arrange the bytes in the right - * order. (This also works on machines of unknown byte order.) - */ - md5_word_t X[16]; - const md5_byte_t *xp = data; - int i; - - for (i = 0; i < 16; ++i, xp += 4) - X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); - -#else /* !ARCH_IS_BIG_ENDIAN */ - - /* - * On little-endian machines, we can process properly aligned data - * without copying it. - */ - md5_word_t xbuf[16]; - const md5_word_t *X; - - if (!((data - (const md5_byte_t *)0) & 3)) { - /* data are properly aligned */ - X = (const md5_word_t *)data; - } else { - /* not aligned */ - memcpy(xbuf, data, 64); - X = xbuf; - } -#endif - -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - - /* Round 1. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ -#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 7, T1); - SET(d, a, b, c, 1, 12, T2); - SET(c, d, a, b, 2, 17, T3); - SET(b, c, d, a, 3, 22, T4); - SET(a, b, c, d, 4, 7, T5); - SET(d, a, b, c, 5, 12, T6); - SET(c, d, a, b, 6, 17, T7); - SET(b, c, d, a, 7, 22, T8); - SET(a, b, c, d, 8, 7, T9); - SET(d, a, b, c, 9, 12, T10); - SET(c, d, a, b, 10, 17, T11); - SET(b, c, d, a, 11, 22, T12); - SET(a, b, c, d, 12, 7, T13); - SET(d, a, b, c, 13, 12, T14); - SET(c, d, a, b, 14, 17, T15); - SET(b, c, d, a, 15, 22, T16); -#undef SET - - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ -#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 1, 5, T17); - SET(d, a, b, c, 6, 9, T18); - SET(c, d, a, b, 11, 14, T19); - SET(b, c, d, a, 0, 20, T20); - SET(a, b, c, d, 5, 5, T21); - SET(d, a, b, c, 10, 9, T22); - SET(c, d, a, b, 15, 14, T23); - SET(b, c, d, a, 4, 20, T24); - SET(a, b, c, d, 9, 5, T25); - SET(d, a, b, c, 14, 9, T26); - SET(c, d, a, b, 3, 14, T27); - SET(b, c, d, a, 8, 20, T28); - SET(a, b, c, d, 13, 5, T29); - SET(d, a, b, c, 2, 9, T30); - SET(c, d, a, b, 7, 14, T31); - SET(b, c, d, a, 12, 20, T32); -#undef SET - - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 5, 4, T33); - SET(d, a, b, c, 8, 11, T34); - SET(c, d, a, b, 11, 16, T35); - SET(b, c, d, a, 14, 23, T36); - SET(a, b, c, d, 1, 4, T37); - SET(d, a, b, c, 4, 11, T38); - SET(c, d, a, b, 7, 16, T39); - SET(b, c, d, a, 10, 23, T40); - SET(a, b, c, d, 13, 4, T41); - SET(d, a, b, c, 0, 11, T42); - SET(c, d, a, b, 3, 16, T43); - SET(b, c, d, a, 6, 23, T44); - SET(a, b, c, d, 9, 4, T45); - SET(d, a, b, c, 12, 11, T46); - SET(c, d, a, b, 15, 16, T47); - SET(b, c, d, a, 2, 23, T48); -#undef SET - - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ -#define I(x, y, z) ((y) ^ ((x) | ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 6, T49); - SET(d, a, b, c, 7, 10, T50); - SET(c, d, a, b, 14, 15, T51); - SET(b, c, d, a, 5, 21, T52); - SET(a, b, c, d, 12, 6, T53); - SET(d, a, b, c, 3, 10, T54); - SET(c, d, a, b, 10, 15, T55); - SET(b, c, d, a, 1, 21, T56); - SET(a, b, c, d, 8, 6, T57); - SET(d, a, b, c, 15, 10, T58); - SET(c, d, a, b, 6, 15, T59); - SET(b, c, d, a, 13, 21, T60); - SET(a, b, c, d, 4, 6, T61); - SET(d, a, b, c, 11, 10, T62); - SET(c, d, a, b, 2, 15, T63); - SET(b, c, d, a, 9, 21, T64); -#undef SET - - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ - pms->abcd[0] += a; - pms->abcd[1] += b; - pms->abcd[2] += c; - pms->abcd[3] += d; -} - -void -md5_init(md5_state_t *pms) -{ - pms->count[0] = pms->count[1] = 0; - pms->abcd[0] = 0x67452301; - pms->abcd[1] = 0xefcdab89; - pms->abcd[2] = 0x98badcfe; - pms->abcd[3] = 0x10325476; -} - -void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) -{ - const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; - md5_word_t nbits = (md5_word_t)(nbytes << 3); - - if (nbytes <= 0) - return; - - /* Update the message length. */ - pms->count[1] += nbytes >> 29; - pms->count[0] += nbits; - if (pms->count[0] < nbits) - pms->count[1]++; - - /* Process an initial partial block. */ - if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - - memcpy(pms->buf + offset, p, copy); - if (offset + copy < 64) - return; - p += copy; - left -= copy; - md5_process(pms, pms->buf); - } - - /* Process full blocks. */ - for (; left >= 64; p += 64, left -= 64) - md5_process(pms, p); - - /* Process a final partial block. */ - if (left) - memcpy(pms->buf, p, left); -} - -void -md5_finish(md5_state_t *pms, md5_byte_t digest[16]) -{ - static const md5_byte_t pad[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - md5_byte_t data[8]; - int i; - - /* Save the length before padding. */ - for (i = 0; i < 8; ++i) - data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); - /* Pad to 56 bytes mod 64. */ - md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); - /* Append the length. */ - md5_append(pms, data, 8); - for (i = 0; i < 16; ++i) - digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); -} diff -Nru fdupes-1.51/.svn/pristine/35/353762497616f46139c0f37010f673361d6221bc.svn-base fdupes-1.6.1/.svn/pristine/35/353762497616f46139c0f37010f673361d6221bc.svn-base --- fdupes-1.51/.svn/pristine/35/353762497616f46139c0f37010f673361d6221bc.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/35/353762497616f46139c0f37010f673361d6221bc.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -- A bug with -S shows wrong results. - -- A bug causes the following behavior: - - $ fdupes --symlinks testdir - testdir/with spaces b - testdir/with spaces a - - testdir/zero_b - testdir/zero_a - - testdir/symlink_two - testdir/twice_one - - $ cp testdir/two testdir/two_again - $ fdupes --symlinks testdir - testdir/two_again - testdir/two - testdir/twice_one - testdir/symlink_two - - testdir/with spaces b - testdir/with spaces a - - testdir/zero_b - testdir/zero_a - - ** This is not the desired behavior. Likewise: - - $ fdupes testdir - testdir/with spaces b - testdir/with spaces a - - testdir/zero_b - testdir/zero_a - - testdir/twice_one - testdir/two - - $ fdupes --symlinks testdir - testdir/with spaces b - testdir/with spaces a - - testdir/zero_b - testdir/zero_a - - testdir/symlink_two - testdir/twice_one - -- Don't assume that stat always works. - -- Add partial checksumming where instead of MD5ing whole - files we MD5 and compare every so many bytes, caching - these partial results for subsequent comparisons. - -- Option -R should not have to be separated from the rest, - such that "fdupes -dR testdir", "fdupes -d -R testdir", - "fdupes -Rd testdir", etc., all yield the same results. - -- Add option to highlight or identify symlinked files (suggest - using --classify to identify symlinks with @ suffix... when - specified, files containing @ are listed using \@). - -- Consider autodeletion option without user intervention. - -- Consider option to match only to files in specific directory. - -- Do a little commenting, to avoid rolling eyes and/or snickering. - -- Fix problem where MD5 collisions will result in one of the - files not being registered (causing it to be ignored). - diff -Nru fdupes-1.51/.svn/pristine/44/4430bb02f6ed700d4408eb307b25f8b1a25d93de.svn-base fdupes-1.6.1/.svn/pristine/44/4430bb02f6ed700d4408eb307b25f8b1a25d93de.svn-base --- fdupes-1.51/.svn/pristine/44/4430bb02f6ed700d4408eb307b25f8b1a25d93de.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/44/4430bb02f6ed700d4408eb307b25f8b1a25d93de.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -five diff -Nru fdupes-1.51/.svn/pristine/4a/4a4121ecd766ed16943a0c7b54c18f743e90c3f6.svn-base fdupes-1.6.1/.svn/pristine/4a/4a4121ecd766ed16943a0c7b54c18f743e90c3f6.svn-base --- fdupes-1.51/.svn/pristine/4a/4a4121ecd766ed16943a0c7b54c18f743e90c3f6.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/4a/4a4121ecd766ed16943a0c7b54c18f743e90c3f6.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -four diff -Nru fdupes-1.51/.svn/pristine/4d/4d40fc46ac7632656e7b7ed5c6a47011695e1335.svn-base fdupes-1.6.1/.svn/pristine/4d/4d40fc46ac7632656e7b7ed5c6a47011695e1335.svn-base --- fdupes-1.51/.svn/pristine/4d/4d40fc46ac7632656e7b7ed5c6a47011695e1335.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/4d/4d40fc46ac7632656e7b7ed5c6a47011695e1335.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -link recursed_a \ No newline at end of file diff -Nru fdupes-1.51/.svn/pristine/4d/4db195b8aa934d450b907c7f6d194f9d1eadf992.svn-base fdupes-1.6.1/.svn/pristine/4d/4db195b8aa934d450b907c7f6d194f9d1eadf992.svn-base --- fdupes-1.51/.svn/pristine/4d/4db195b8aa934d450b907c7f6d194f9d1eadf992.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/4d/4db195b8aa934d450b907c7f6d194f9d1eadf992.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -Introduction --------------------------------------------------------------------- -FDUPES is a program for identifying duplicate files residing -within specified directories. - - -Usage --------------------------------------------------------------------- -Usage: fdupes [options] DIRECTORY... - - -r --recurse for every directory given follow subdirectories - encountered within - -R --recurse: for each directory given after this option follow - subdirectories encountered within - -s --symlinks follow symlinks - -H --hardlinks normally, when two or more files point to the same - disk area they are treated as non-duplicates; this - option will change this behavior - -n --noempty exclude zero-length files from consideration - -f --omitfirst omit the first file in each set of matches - -1 --sameline list each set of matches on a single line - -S --size show size of duplicate files - -q --quiet hide progress indicator - -d --delete prompt user for files to preserve and delete all - others; important: under particular circumstances, - data may be lost when using this option together - with -s or --symlinks, or when specifying a - particular directory more than once; refer to the - fdupes documentation for additional information - -v --version display fdupes version - -h --help display this help message - -Unless -1 or --sameline is specified, duplicate files are listed -together in groups, each file displayed on a separate line. The -groups are then separated from each other by blank lines. - -When -1 or --sameline is specified, spaces and backslash characters (\) -appearing in a filename are preceded by a backslash character. For -instance, "with spaces" becomes "with\ spaces". - -When using -d or --delete, care should be taken to insure against -accidental data loss. While no information will be immediately -lost, using this option together with -s or --symlink can lead -to confusing information being presented to the user when prompted -for files to preserve. Specifically, a user could accidentally -preserve a symlink while deleting the file it points to. A similar -problem arises when specifying a particular directory more than -once. All files within that directory will be listed as their own -duplicates, leading to data loss should a user preserve a file -without its "duplicate" (the file itself!). - - -Contact Information for Adrian Lopez --------------------------------------------------------------------- -email: adrian2@caribe.net - - -Legal Information --------------------------------------------------------------------- -FDUPES Copyright (c) 1999 Adrian Lopez - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation files -(the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, -and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff -Nru fdupes-1.51/.svn/pristine/6f/6f02f5c07dcf985ec62ac8013e28ab399d428f7a.svn-base fdupes-1.6.1/.svn/pristine/6f/6f02f5c07dcf985ec62ac8013e28ab399d428f7a.svn-base --- fdupes-1.51/.svn/pristine/6f/6f02f5c07dcf985ec62ac8013e28ab399d428f7a.svn-base 2013-04-20 18:05:49.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/6f/6f02f5c07dcf985ec62ac8013e28ab399d428f7a.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -The following list, organized by fdupes version, documents changes -to fdupes. Every item on the list includes, inside square brackets, -a list of indentifiers referring to the people who contributed -that particular item. When more than one person is listed the person -who contributed the patch or idea appears first, followed by -those who've otherwise worked on that item. For a list of -contributors names and identifiers please see the CONTRIBUTORS file. - - -Changes from 1.50 to 1.51 - -- Added support for 64-bit file offsets on 32-bit systems. -- Using tty for interactive input instead of regular stdin. This is to - allow feeding filenames via stdin in future versions of fdupes without - breaking interactive deletion feature. -- Fixed some typos in --help. -- Turned C++ style comments into C style comments. - -Changes from 1.40 to 1.50-PR2 - -- Fixed memory leak. [JB] -- Added "--summarize" option. [AL] -- Added "--recurse:" selective recursion option. [AL] -- Added "--noprompt" option for totally automated deletion of - duplicate files. -- Now sorts duplicates (old to new) for consistent order when - listing or deleteing duplicate files. -- Now tests for early matching of files, which should help speed up - the matching process when large files are involved. -- Added warning whenever a file cannot be deleted. [CHL, AL] -- Fixed bug where some files would not be closed after failure. [AL] -- Fixed bug where confirmmatch() function wouldn't always deal - properly with zero-length files. [AL] -- Fixed bug where progress indicator would not be cleared - when no files were found. [AL] -- Removed experimental red-black tree code (it was slower on - my system than the default code). [AL] -- Modified md5/md5.c to avoid compiler warning. [CHL] -- Changes to fdupes.c for compilation under platforms where - getopt_long is unavailable. [LR, AL] -- Changes to help text for clarity. [AL] -- Various changes and improvements to Makefile. [PB, AL] - -Changes from 1.31 to 1.40 - -- Added option to omit the first file in each group - of matches. [LM, AL] -- Added escaping of filenames containing spaces when - sameline option is specified. [AL] -- Changed version indicator format from "fdupes version X.Y" - to the simpler "fdupes X.Y". [AL] -- Changed ordering of options appearing in the help - text (--help), manpage, and README file. [AL] - -Changes from 1.30 to 1.31 - -- Added interactive option to preserve all files during - delete procedure (something similar was already in - place, but now it's official). [AL] -- Updated delete procedure prompt format. [AL] -- Cosmetic code changes. [AL] - -Changes from 1.20 to 1.30 - -- Added size option to display size of duplicates. [LB, AL] -- Added missing typecast for proper compilation under g++. [LB] -- Better handling of errors occurring during retrieval - of a file's signature. [KK, AL] -- No longer displays an error message when specified - directories contain no files. [AL] -- Added red-black tree structure (experimental compile-time - option, disabled by default). [AL] - -Changes from 1.12 to 1.20 - -- Fixed bug where program would crash when files being - scanned were named pipes or sockets. [FD] -- Fix against security risk resulting from the use of a - temporary file to store md5sum output. [FD, AL] -- Using an external md5sum program is now optional. Started - using L. Peter Deutsh's MD5 library instead. [FD, AL] -- Added hardlinks option to distinguish between hard links - and actual duplicate files. [FD, AL] -- Added noempty option to exclude zero-length files - from consideration [AL] - -Changes from 1.11 to 1.12 - -- Improved handling of extremely long input on preserve - prompt (delete option). [SSD, AL] - -Changes from 1.1 to 1.11 - -- Started checking file sizes before signatures - for better performance. [AB, AL] -- Added fdupes manpage. [AB, AL] - -Changes from 1.0 to 1.1 - -- Added delete option for semi-automatic deletion - of duplicate files. [AL] - diff -Nru fdupes-1.51/.svn/pristine/70/706833cca7f1bd17799bd19d7341c4528570654c.svn-base fdupes-1.6.1/.svn/pristine/70/706833cca7f1bd17799bd19d7341c4528570654c.svn-base --- fdupes-1.51/.svn/pristine/70/706833cca7f1bd17799bd19d7341c4528570654c.svn-base 2013-04-20 18:05:49.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/70/706833cca7f1bd17799bd19d7341c4528570654c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -# -# fdupes Makefile -# - -##################################################################### -# Standand User Configuration Section # -##################################################################### - -# -# PREFIX indicates the base directory used as the basis for the -# determination of the actual installation directories. -# Suggested values are "/usr/local", "/usr", "/pkgs/fdupes-$(VERSION)" -# -PREFIX = /usr/local - -# -# When compiling for 32-bit systems, FILEOFFSET_64BIT must be enabled -# for fdupes to handle files greater than (2<<31)-1 bytes. -# -FILEOFFSET_64BIT = -D_FILE_OFFSET_BITS=64 - -# -# Certain platforms do not support long options (command line options). -# To disable long options, uncomment the following line. -# -#OMIT_GETOPT_LONG = -DOMIT_GETOPT_LONG - -# -# To use the md5sum program for calculating signatures (instead of the -# built in MD5 message digest routines) uncomment the following -# line (try this if you're having trouble with built in code). -# -#EXTERNAL_MD5 = -DEXTERNAL_MD5=\"md5sum\" - -##################################################################### -# Developer Configuration Section # -##################################################################### - -# -# VERSION determines the program's version number. -# -include Makefile.inc/VERSION - -# -# PROGRAM_NAME determines the installation name and manual page name -# -PROGRAM_NAME=fdupes - -# -# BIN_DIR indicates directory where program is to be installed. -# Suggested value is "$(PREFIX)/bin" -# -BIN_DIR = $(PREFIX)/bin - -# -# MAN_DIR indicates directory where the fdupes man page is to be -# installed. Suggested value is "$(PREFIX)/man/man1" -# -MAN_BASE_DIR = $(PREFIX)/man -MAN_DIR = $(MAN_BASE_DIR)/man1 -MAN_EXT = 1 - -# -# Required External Tools -# - -INSTALL = install # install : UCB/GNU Install compatiable -#INSTALL = ginstall - -RM = rm -f - -MKDIR = mkdir -p -#MKDIR = mkdirhier -#MKDIR = mkinstalldirs - - -# -# Make Configuration -# -CC = gcc -COMPILER_OPTIONS = -Wall -O -g - -CFLAGS= $(COMPILER_OPTIONS) -I. -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(OMIT_GETOPT_LONG) $(FILEOFFSET_64BIT) - -INSTALL_PROGRAM = $(INSTALL) -c -m 0755 -INSTALL_DATA = $(INSTALL) -c -m 0644 - -# -# ADDITIONAL_OBJECTS - some platforms will need additional object files -# to support features not supplied by their vendor. Eg: GNU getopt() -# -#ADDITIONAL_OBJECTS = getopt.o - -OBJECT_FILES = fdupes.o md5/md5.o $(ADDITIONAL_OBJECTS) - -##################################################################### -# no need to modify anything beyond this point # -##################################################################### - -all: fdupes - -fdupes: $(OBJECT_FILES) - $(CC) $(CFLAGS) -o fdupes $(OBJECT_FILES) - -installdirs: - test -d $(BIN_DIR) || $(MKDIR) $(BIN_DIR) - test -d $(MAN_DIR) || $(MKDIR) $(MAN_DIR) - -install: fdupes installdirs - $(INSTALL_PROGRAM) fdupes $(BIN_DIR)/$(PROGRAM_NAME) - $(INSTALL_DATA) fdupes.1 $(MAN_DIR)/$(PROGRAM_NAME).$(MAN_EXT) - -clean: - $(RM) $(OBJECT_FILES) - $(RM) fdupes - $(RM) *~ md5/*~ - -love: - @echo You\'re not my type. Go find a human partner. diff -Nru fdupes-1.51/.svn/pristine/7b/7bbef45b3bc70855010e02460717643125c3beca.svn-base fdupes-1.6.1/.svn/pristine/7b/7bbef45b3bc70855010e02460717643125c3beca.svn-base --- fdupes-1.51/.svn/pristine/7b/7bbef45b3bc70855010e02460717643125c3beca.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/7b/7bbef45b3bc70855010e02460717643125c3beca.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -two diff -Nru fdupes-1.51/.svn/pristine/7d/7db95721ce0051d62b982e79febd2726654a96fa.svn-base fdupes-1.6.1/.svn/pristine/7d/7db95721ce0051d62b982e79febd2726654a96fa.svn-base --- fdupes-1.51/.svn/pristine/7d/7db95721ce0051d62b982e79febd2726654a96fa.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/7d/7db95721ce0051d62b982e79febd2726654a96fa.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -# -# fdupes Makefile -# - -##################################################################### -# Standand User Configuration Section # -##################################################################### - -# -# PREFIX indicates the base directory used as the basis for the -# determination of the actual installation directories. -# Suggested values are "/usr/local", "/usr", "/pkgs/fdupes-$(VERSION)" -# -PREFIX = /usr/local - -# -# Certain platforms do not support long options (command line options). -# To disable long options, uncomment the following line. -# -#OMIT_GETOPT_LONG = -DOMIT_GETOPT_LONG - -# -# To use the md5sum program for calculating signatures (instead of the -# built in MD5 message digest routines) uncomment the following -# line (try this if you're having trouble with built in code). -# -#EXTERNAL_MD5 = -DEXTERNAL_MD5=\"md5sum\" - -##################################################################### -# Developer Configuration Section # -##################################################################### - -# -# VERSION determines the program's version number. -# -include Makefile.inc/VERSION - -# -# PROGRAM_NAME determines the installation name and manual page name -# -PROGRAM_NAME=fdupes - -# -# BIN_DIR indicates directory where program is to be installed. -# Suggested value is "$(PREFIX)/bin" -# -BIN_DIR = $(PREFIX)/bin - -# -# MAN_DIR indicates directory where the fdupes man page is to be -# installed. Suggested value is "$(PREFIX)/man/man1" -# -MAN_BASE_DIR = $(PREFIX)/man -MAN_DIR = $(MAN_BASE_DIR)/man1 -MAN_EXT = 1 - -# -# Required External Tools -# - -INSTALL = install # install : UCB/GNU Install compatiable -#INSTALL = ginstall - -RM = rm -f - -MKDIR = mkdir -p -#MKDIR = mkdirhier -#MKDIR = mkinstalldirs - - -# -# Make Configuration -# -CC = gcc -COMPILER_OPTIONS = -Wall -O -g - -CFLAGS= $(COMPILER_OPTIONS) -I. -DVERSION=\"$(VERSION)\" $(EXTERNAL_MD5) $(EXPERIMENTAL_RBTREE) $(OMIT_GETOPT_LONG) - -INSTALL_PROGRAM = $(INSTALL) -c -m 0755 -INSTALL_DATA = $(INSTALL) -c -m 0644 - -# -# ADDITIONAL_OBJECTS - some platforms will need additional object files -# to support features not supplied by their vendor. Eg: GNU getopt() -# -#ADDITIONAL_OBJECTS = getopt.o - -OBJECT_FILES = fdupes.o md5/md5.o $(ADDITIONAL_OBJECTS) - -##################################################################### -# no need to modify anything beyond this point # -##################################################################### - -all: fdupes - -fdupes: $(OBJECT_FILES) - $(CC) $(CFLAGS) -o fdupes $(OBJECT_FILES) - -installdirs: - test -d $(BIN_DIR) || $(MKDIR) $(BIN_DIR) - test -d $(MAN_DIR) || $(MKDIR) $(MAN_DIR) - -install: fdupes installdirs - $(INSTALL_PROGRAM) fdupes $(BIN_DIR)/$(PROGRAM_NAME) - $(INSTALL_DATA) fdupes.1 $(MAN_DIR)/$(PROGRAM_NAME).$(MAN_EXT) - -clean: - $(RM) $(OBJECT_FILES) - $(RM) fdupes - $(RM) *~ md5/*~ - -love: - @echo You\'re not my type. Go find a human partner. diff -Nru fdupes-1.51/.svn/pristine/85/8501050f63779a4a0ddae46d72ce8585754d87f6.svn-base fdupes-1.6.1/.svn/pristine/85/8501050f63779a4a0ddae46d72ce8585754d87f6.svn-base --- fdupes-1.51/.svn/pristine/85/8501050f63779a4a0ddae46d72ce8585754d87f6.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/85/8501050f63779a4a0ddae46d72ce8585754d87f6.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -.TH FDUPES 1 -.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection -.\" other parms are allowed: see man(7), man(1) -.SH NAME -fdupes \- finds duplicate files in a given set of directories -.SH SYNOPSIS -.B fdupes -[ -.I options -] -.I DIRECTORY -\|.\|.\|. - -.SH "DESCRIPTION" -Searches the given path for duplicate files. Such files are found by -comparing file sizes and MD5 signatures, followed by a -byte-by-byte comparison. - -.SH OPTIONS -.TP -.B -r --recurse -for every directory given follow subdirectories encountered within -.TP -.B -R --recurse: -for each directory given after this option follow subdirectories -encountered within -.TP -.B -s --symlinks -follow symlinked directories -.TP -.B -H --hardlinks -normally, when two or more files point to the same disk area they are -treated as non-duplicates; this option will change this behavior -.TP -.B -n --noempty -exclude zero-length files from consideration -.TP -.B -f --omitfirst -omit the first file in each set of matches -.TP -.B -1 --sameline -list each set of matches on a single line -.TP -.B -S --size -show size of duplicate files -.TP -.B -q --quiet -hide progress indicator -.TP -.B -d --delete -prompt user for files to preserve, deleting all others (see -.B CAVEATS -below) -.TP -.B -N --noprompt -when used together with --delete, preserve the first file in each -set of duplicates and delete the others without prompting the user -.TP -.B -v --version -display fdupes version -.TP -.B -h --help -displays help -.SH "SEE ALSO" -.\" Always quote multiple words for .SH -.BR md5sum (1) -.SH NOTES -Unless -.B -1 -or -.B --sameline -is specified, duplicate files are listed -together in groups, each file displayed on a separate line. The -groups are then separated from each other by blank lines. - -When -.B -1 -or -.B --sameline -is specified, spaces and backslash characters (\fB\e\fP) appearing -in a filename are preceded by a backslash character. -.SH CAVEATS -If fdupes returns with an error message such as -.B fdupes: error invoking md5sum -it means the program has been compiled to use an external -program to calculate MD5 signatures (otherwise, fdupes uses -interal routines for this purpose), and an error has occurred -while attempting to execute it. If this is the case, the -specified program should be properly installed prior -to running fdupes. - -When using -.B \-d -or -.BR \-\-delete , -care should be taken to insure against -accidental data loss. - -When used together with options -.B \-s -or -.BR \-\-symlink , -a user could accidentally -preserve a symlink while deleting the file it points to. - -Furthermore, when specifying a particular directory more than -once, all files within that directory will be listed as their -own duplicates, leading to data loss should a user preserve a -file without its "duplicate" (the file itself!). - -.SH AUTHOR -Adrian Lopez - diff -Nru fdupes-1.51/.svn/pristine/99/99346e4e318333b4785bb199997c1fcc2be7546d.svn-base fdupes-1.6.1/.svn/pristine/99/99346e4e318333b4785bb199997c1fcc2be7546d.svn-base --- fdupes-1.51/.svn/pristine/99/99346e4e318333b4785bb199997c1fcc2be7546d.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/99/99346e4e318333b4785bb199997c1fcc2be7546d.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -with spaces diff -Nru fdupes-1.51/.svn/pristine/a3/a3170b78ced4cd2e8302c6d80436a1cd5a908f6f.svn-base fdupes-1.6.1/.svn/pristine/a3/a3170b78ced4cd2e8302c6d80436a1cd5a908f6f.svn-base --- fdupes-1.51/.svn/pristine/a3/a3170b78ced4cd2e8302c6d80436a1cd5a908f6f.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/a3/a3170b78ced4cd2e8302c6d80436a1cd5a908f6f.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -# -# VERSION determines the program's version number. -# - -VERSION = 1.50-PR2 diff -Nru fdupes-1.51/.svn/pristine/a3/a34e525c92d7acf1e92ea5b99eaabaeb8ff4d1d6.svn-base fdupes-1.6.1/.svn/pristine/a3/a34e525c92d7acf1e92ea5b99eaabaeb8ff4d1d6.svn-base --- fdupes-1.51/.svn/pristine/a3/a34e525c92d7acf1e92ea5b99eaabaeb8ff4d1d6.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/a3/a34e525c92d7acf1e92ea5b99eaabaeb8ff4d1d6.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -link two \ No newline at end of file diff -Nru fdupes-1.51/.svn/pristine/b9/b9cb24548c74e0c61ae5d6749fc756edd1418f9a.svn-base fdupes-1.6.1/.svn/pristine/b9/b9cb24548c74e0c61ae5d6749fc756edd1418f9a.svn-base --- fdupes-1.51/.svn/pristine/b9/b9cb24548c74e0c61ae5d6749fc756edd1418f9a.svn-base 2013-04-20 18:21:49.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/b9/b9cb24548c74e0c61ae5d6749fc756edd1418f9a.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -# -# VERSION determines the program's version number. -# - -VERSION = 1.51 diff -Nru fdupes-1.51/.svn/pristine/c7/c7059bb19433cc3cabaa6236c83d56668a843dd2.svn-base fdupes-1.6.1/.svn/pristine/c7/c7059bb19433cc3cabaa6236c83d56668a843dd2.svn-base --- fdupes-1.51/.svn/pristine/c7/c7059bb19433cc3cabaa6236c83d56668a843dd2.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/c7/c7059bb19433cc3cabaa6236c83d56668a843dd2.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -one diff -Nru fdupes-1.51/.svn/pristine/cf/cfa698ef88230fbe6862cb300268a3a647ecc71d.svn-base fdupes-1.6.1/.svn/pristine/cf/cfa698ef88230fbe6862cb300268a3a647ecc71d.svn-base --- fdupes-1.51/.svn/pristine/cf/cfa698ef88230fbe6862cb300268a3a647ecc71d.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/cf/cfa698ef88230fbe6862cb300268a3a647ecc71d.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -six diff -Nru fdupes-1.51/.svn/pristine/e4/e490ace58b9e686f8c4858864e72de0fbc5a4f8d.svn-base fdupes-1.6.1/.svn/pristine/e4/e490ace58b9e686f8c4858864e72de0fbc5a4f8d.svn-base --- fdupes-1.51/.svn/pristine/e4/e490ace58b9e686f8c4858864e72de0fbc5a4f8d.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/e4/e490ace58b9e686f8c4858864e72de0fbc5a4f8d.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -The MD5 library code residing within this directory was written -by L. Peter Deutsch. Although distributed here with fdupes, the -license for his MD5 library is different from the fdupes license. -Please look md5.c or md5.h for licensing information. diff -Nru fdupes-1.51/.svn/pristine/e7/e73a4cd50904e0af47fda6e98d066e3436e9820a.svn-base fdupes-1.6.1/.svn/pristine/e7/e73a4cd50904e0af47fda6e98d066e3436e9820a.svn-base --- fdupes-1.51/.svn/pristine/e7/e73a4cd50904e0af47fda6e98d066e3436e9820a.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/e7/e73a4cd50904e0af47fda6e98d066e3436e9820a.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* - Copyright (C) 1999 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost@aladdin.com - - */ -/*$Id: md5.h $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321. - It is derived directly from the text of the RFC and not from the - reference implementation. - - The original and principal author of md5.h is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); - added conditionalization for C++ compilation from Martin - Purschke . - 1999-05-03 lpd Original version. - */ - -#ifndef md5_INCLUDED -# define md5_INCLUDED - -/* - * This code has some adaptations for the Ghostscript environment, but it - * will compile and run correctly in any environment with 8-bit chars and - * 32-bit ints. Specifically, it assumes that if the following are - * defined, they have the same meaning as in Ghostscript: P1, P2, P3, - * ARCH_IS_BIG_ENDIAN. - */ - -typedef unsigned char md5_byte_t; /* 8-bit byte */ -typedef unsigned int md5_word_t; /* 32-bit word */ - -/* Define the state of the MD5 Algorithm. */ -typedef struct md5_state_s { - md5_word_t count[2]; /* message length in bits, lsw first */ - md5_word_t abcd[4]; /* digest buffer */ - md5_byte_t buf[64]; /* accumulate block */ -} md5_state_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Initialize the algorithm. */ -#ifdef P1 -void md5_init(P1(md5_state_t *pms)); -#else -void md5_init(md5_state_t *pms); -#endif - -/* Append a string to the message. */ -#ifdef P3 -void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes)); -#else -void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); -#endif - -/* Finish the message and return the digest. */ -#ifdef P2 -void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16])); -#else -void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); -#endif - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif /* md5_INCLUDED */ - - - - diff -Nru fdupes-1.51/.svn/pristine/f7/f73d64088b09a8b3af29f141d61ce9e88d99fd02.svn-base fdupes-1.6.1/.svn/pristine/f7/f73d64088b09a8b3af29f141d61ce9e88d99fd02.svn-base --- fdupes-1.51/.svn/pristine/f7/f73d64088b09a8b3af29f141d61ce9e88d99fd02.svn-base 2013-04-20 17:00:09.000000000 +0000 +++ fdupes-1.6.1/.svn/pristine/f7/f73d64088b09a8b3af29f141d61ce9e88d99fd02.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -Installing fdupes --------------------------------------------------------------------- -To install the program, issue the following commands: - -make fdupes -su root -make install - -This will install the program in /usr/local/bin. You may change this -to a different location by editing the Makefile. Please refer to -the Makefile for an explanation of compile-time options. If you're -having trouble compiling, please take a look at the Makefile. - -UPGRADING NOTE: When upgrading from a version prior to 1.2, it should -be noted that the default installation directory for the fdupes man -page has changed from "/usr/man" to "/usr/local/man". If installing -to the default location you should delete the old man page before -proceeding. This file would be named "/usr/man/man1/fdupes.1". - -A test directory is included so that you may familiarise yourself -with the way fdupes operates. You may test the program before -installing it by issuing a command such as "./fdupes testdir" -or "./fdupes -r testdir", just to name a couple of examples. Refer -to the documentation for information on valid options. - Binary files /tmp/tmpZW9m2u/uPXSflAbWc/fdupes-1.51/.svn/wc.db and /tmp/tmpZW9m2u/UyQUsQvdVV/fdupes-1.6.1/.svn/wc.db differ