Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete option to preserve no duplicates #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions fdupes.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty)
int max = 0;
int x;
int i;
int min_files_preserved;

curfile = files;

Expand Down Expand Up @@ -836,7 +837,8 @@ void deletefiles(file_t *files, int prompt, FILE *tty)
else /* prompt for files to preserve */

do {
printf("Set %d of %d, preserve files [1 - %d, all]",
min_files_preserved = 1;
printf("Set %d of %d, preserve files [1 - %d, all, none!]",
curgroup, groups, counter);
if (ISFLAG(flags, F_SHOWSIZE)) printf(" (%lld byte%seach)", (long long int)files->size,
(files->size != 1) ? "s " : " ");
Expand Down Expand Up @@ -870,6 +872,8 @@ void deletefiles(file_t *files, int prompt, FILE *tty)
token = strtok(preservestr, " ,\n");

while (token != NULL) {
/* if none! is the only token, remove all files */
if (strcasecmp(token, "none!") == 0) min_files_preserved = 0;
if (strcasecmp(token, "all") == 0)
for (x = 0; x <= counter; x++) preserve[x] = 1;

Expand All @@ -881,7 +885,7 @@ void deletefiles(file_t *files, int prompt, FILE *tty)
}

for (sum = 0, x = 1; x <= counter; x++) sum += preserve[x];
} while (sum < 1); /* make sure we've preserved at least one file */
} while (sum < min_files_preserved); /* make sure we've preserved at least min files */

printf("\n");

Expand Down