Skip to content

Commit

Permalink
fdupes-1.40
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlopezroche authored and jobermayr committed Mar 15, 2001
1 parent 73d9ab1 commit e739114
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 60 deletions.
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ those who've otherwise worked on that item. For a list of
contributors names and identifiers please see the CONTRIBUTORS file.


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
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ on their contributions. Names are listed in alphabetical order.
[FD] Frank DENIS aka Jedi/Sector One aka DJ Chrysalis <[email protected]>
[KK] Kresimir Kukulj <[email protected]>
[LB] Laurent Bonnaud <[email protected]>
[LM] Luca Montecchiani <[email protected]>
[SSD] Steven S. Dick <[email protected]>

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MANPAGEDIR = /usr/local/man
#
# VERSION determines the program's version number.
#
VERSION = "1.31"
VERSION = "1.40"

#
# To use the md5sum program for calculating signatures (instead of the
Expand Down Expand Up @@ -42,7 +42,7 @@ install: fdupes
cp fdupes.1 $(MANPAGEDIR)/man1

tarball: clean
tar --directory=.. -c -z -v -f ../fdupes-$(VERSION).tar.gz fdupes
tar --directory=.. -c -z -v -f ../fdupes-$(VERSION).tar.gz fdupes-$(VERSION)

clean:
rm -f *.o
Expand Down
39 changes: 22 additions & 17 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,33 @@ Usage
--------------------------------------------------------------------
Usage: fdupes [options] DIRECTORY...

-r --recurse include files residing in subdirectories
-q --quiet hide progress indicator
-1 --sameline list duplicates on a single line
-S --size show size of duplicate files
-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
-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
-r --recurse include files residing in subdirectories
-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
Expand Down
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
- Add option to highlight or identify symlinked files.
- Verify correctness of red-black tree algorithm. Optimize.
- Add quoting of filenames containing spaces when using --sameline.
- Fix problem where MD5 collisions will result in one of the
files not being registered (causing it to be ignored).

28 changes: 19 additions & 9 deletions fdupes.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ byte-by-byte comparison.
.B -r --recurse
include files residing in subdirectories
.TP
.B -q --quiet
hide progress indicator
.TP
.B -1 --sameline
list duplicates on a single line
.TP
.B -S --size
show size of duplicate files
.TP
.B -s --symlinks
follow symlinked directories
.TP
Expand All @@ -40,6 +31,18 @@ treated as non-duplicates; this option will change this behavior
.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
Expand All @@ -61,6 +64,13 @@ or
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
Expand Down
104 changes: 73 additions & 31 deletions fdupes.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@
#define ISFLAG(a,b) ((a & b) == b)
#define SETFLAG(a,b) (a |= b)

#define F_RECURSE 0x01
#define F_HIDEPROGRESS 0x02
#define F_DSAMELINE 0x04
#define F_FOLLOWLINKS 0x08
#define F_DELETEFILES 0x10
#define F_EXCLUDEEMPTY 0x20
#define F_CONSIDERHARDLINKS 0x40
#define F_SHOWSIZE 0x80
#define F_RECURSE 0x001
#define F_HIDEPROGRESS 0x002
#define F_DSAMELINE 0x004
#define F_FOLLOWLINKS 0x008
#define F_DELETEFILES 0x010
#define F_EXCLUDEEMPTY 0x020
#define F_CONSIDERHARDLINKS 0x040
#define F_SHOWSIZE 0x080
#define F_OMITFIRST 0x100

char *program_name;

Expand Down Expand Up @@ -89,6 +90,38 @@ void errormsg(char *message, ...)
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;

Expand Down Expand Up @@ -554,18 +587,22 @@ void printmatches(file_t *files)

while (files != NULL) {
if (files->hasdupes) {
if (ISFLAG(flags, F_SHOWSIZE)) printf("%ld byte%seach:\n", files->size,
(files->size != 1) ? "s " : " ");
printf("%s%c", files->d_name, ISFLAG(flags, F_DSAMELINE)?' ':'\n');
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;
}
}
Expand Down Expand Up @@ -705,23 +742,24 @@ void help_text()
{
printf("Usage: fdupes [options] DIRECTORY...\n\n");

printf(" -r --recurse \t\tinclude files residing in subdirectories\n");
printf(" -q --quiet \t\thide progress indicator\n");
printf(" -1 --sameline \t\tlist duplicates on a single line\n");
printf(" -S --size \t\tshow size of duplicate files\n");
printf(" -s --symlinks \t\tfollow symlinks\n");
printf(" -H --hardlinks\t\tnormally, when two or more files point to the same\n");
printf(" \t\tdisk area they are treated as non-duplicates; this\n");
printf(" \t\toption will change this behavior\n");
printf(" -n --noempty \t\texclude zero-length files from consideration\n");
printf(" -d --delete \t\tprompt user for files to preserve and delete all others\n");
printf(" \t\timportant: under particular circumstances, data\n");
printf(" \t\tmay be lost when using this option together with -s\n");
printf(" \t\tor --symlinks, or when specifying a particular\n");
printf(" \t\tdirectory more than once; refer to the fdupes\n");
printf(" \t\tdocumentation for additional information\n");
printf(" -v --version \t\tdisplay fdupes version\n");
printf(" -h --help \t\tdisplay this help message\n\n");
printf(" -r --recurse \tinclude files residing in subdirectories\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(" -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(" -v --version \tdisplay fdupes version\n");
printf(" -h --help \tdisplay this help message\n\n");
}

int main(int argc, char **argv) {
Expand All @@ -738,6 +776,7 @@ int main(int argc, char **argv) {

static struct option long_options[] =
{
{ "omitfirst", 0, 0, 'f' },
{ "recurse", 0, 0, 'r' },
{ "quiet", 0, 0, 'q' },
{ "sameline", 0, 0, '1' },
Expand All @@ -753,8 +792,11 @@ int main(int argc, char **argv) {

program_name = argv[0];

while ((opt = getopt_long(argc, argv, "rq1SsHndvh", long_options, NULL)) != EOF) {
while ((opt = getopt_long(argc, argv, "frq1SsHndvh", long_options, NULL)) != EOF) {
switch (opt) {
case 'f':
SETFLAG(flags, F_OMITFIRST);
break;
case 'r':
SETFLAG(flags, F_RECURSE);
break;
Expand All @@ -780,7 +822,7 @@ int main(int argc, char **argv) {
SETFLAG(flags, F_DELETEFILES);
break;
case 'v':
printf("fdupes version %s\n", VERSION);
printf("fdupes %s\n", VERSION);
exit(0);
case 'h':
help_text();
Expand Down
1 change: 1 addition & 0 deletions testdir/with spaces a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
with spaces
1 change: 1 addition & 0 deletions testdir/with spaces b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
with spaces

0 comments on commit e739114

Please sign in to comment.