Skip to content

Commit

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


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]
Expand Down
2 changes: 1 addition & 1 deletion 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.30"
VERSION = "1.31"

#
# To use the md5sum program for calculating signatures (instead of the
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Usage: fdupes [options] DIRECTORY...
-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 reverse this behavior
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
Expand Down
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- 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
Expand Down
2 changes: 1 addition & 1 deletion fdupes.1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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 reverse this behavior
treated as non-duplicates; this option will change this behavior
.TP
.B -n --noempty
exclude zero-length files from consideration
Expand Down
71 changes: 40 additions & 31 deletions fdupes.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int grokdir(char *dir, file_t **filelistp)
#ifndef EXTERNAL_MD5

/* If EXTERNAL_MD5 is not defined, use L. Peter Deutsch's MD5 library.
*/
*/
char *getcrcsignature(char *filename)
{
int x;
Expand Down Expand Up @@ -254,7 +254,7 @@ char *getcrcsignature(char *filename)
#ifdef EXTERNAL_MD5

/* If EXTERNAL_MD5 is defined, use md5sum program to calculate signatures.
*/
*/
char *getcrcsignature(char *filename)
{
static char signature[256];
Expand Down Expand Up @@ -303,7 +303,7 @@ void purgetree(filetree_t *checktree)

#ifdef EXPERIMENTAL_RBTREE
/* Use a red-black tree structure to store file information.
*/
*/

void rotate_left(filetree_t **root, filetree_t *node)
{
Expand Down Expand Up @@ -523,8 +523,8 @@ file_t *checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
} else return checktree->file;
}

/* Do a bit-for-bit comparison, in case two different files produce the
same signature. Unlikely, to be sure, but better safe than sorry. */
/* 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)
{
Expand Down Expand Up @@ -572,7 +572,7 @@ void printmatches(file_t *files)

void autodelete(file_t *files)
{
int counter = 1;
int counter;
int groups = 0;
int curgroup = 0;
file_t *tmpfile;
Expand All @@ -592,21 +592,23 @@ void autodelete(file_t *files)

while (curfile) {
if (curfile->hasdupes) {
counter = 1;
groups++;

counter = 1;
tmpfile = curfile->duplicates;
while (tmpfile) {
counter++;
tmpfile = tmpfile->duplicates;
}

if ((counter + 1) > max) max = counter + 1;
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);
Expand All @@ -621,20 +623,24 @@ void autodelete(file_t *files)
curgroup++;
counter = 1;
dupelist[counter] = files;
printf("[%d] %s\n", counter++, files->d_name);

printf("[%d] %s\n", counter, files->d_name);

tmpfile = files->duplicates;

while (tmpfile) {
dupelist[counter] = tmpfile;
printf("[%d] %s\n", counter++, tmpfile->d_name);
dupelist[++counter] = tmpfile;
printf("[%d] %s\n", counter, tmpfile->d_name);
tmpfile = tmpfile->duplicates;
}

printf("\n");

do {
printf("Preserve files [%d of %d]", curgroup, groups);
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 " : " ");
(files->size != 1) ? "s " : " ");
printf(": ");
fflush(stdout);

Expand All @@ -643,37 +649,40 @@ void autodelete(file_t *files)
i = strlen(preservestr) - 1;

while (preservestr[i]!='\n'){ /* tail of buffer must be a newline */
tstr = (char*)realloc(preservestr, strlen(preservestr)+ 1 + INPUT_SIZE);
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;
}

if (strcasecmp(preservestr, "all\n") == 0) {
for (x = 1; x < counter; x++) preserve[x] = 1;
} else {
for (x = 1; x < counter; x++) preserve[x] = 0;
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;

token = strtok(preservestr, " ,");

while (token != NULL) {
number = 0;
sscanf(token, "%d", &number);
if (number > 0 && number < counter) preserve[number] = 1;
token = strtok(NULL, " ,");
}
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);
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++) {

for (x = 1; x <= counter; x++) {
if (preserve[x])
printf(" [+] %s\n", dupelist[x]->d_name);
else {
Expand Down Expand Up @@ -703,7 +712,7 @@ void help_text()
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 reverse this behavior\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");
Expand Down
1 change: 0 additions & 1 deletion testdir/recursed_a/six

This file was deleted.

0 comments on commit 73d9ab1

Please sign in to comment.