ncurses-interface.c (fdupes-2.0.0) | : | ncurses-interface.c (fdupes-2.1.0) | ||
---|---|---|---|---|
skipping to change at line 379 | skipping to change at line 379 | |||
int cursor_y; | int cursor_y; | |||
int groupfirstline = 0; | int groupfirstline = 0; | |||
int totallines = 0; | int totallines = 0; | |||
int allocatedgroups = 0; | int allocatedgroups = 0; | |||
int totalgroups = 0; | int totalgroups = 0; | |||
size_t groupindex = 0; | size_t groupindex = 0; | |||
enum linestyle linestyle; | enum linestyle linestyle; | |||
int preservecount; | int preservecount; | |||
int deletecount; | int deletecount; | |||
int unresolvedcount; | int unresolvedcount; | |||
int totaldeleted; | ||||
size_t globaldeletiontally = 0; | size_t globaldeletiontally = 0; | |||
double deletedbytes; | ||||
int row; | int row; | |||
int x; | int x; | |||
int g; | int g; | |||
wint_t wch; | wint_t wch; | |||
int keyresult; | int keyresult; | |||
int cy; | int cy; | |||
int f; | int f; | |||
int to; | ||||
wchar_t *commandbuffer; | wchar_t *commandbuffer; | |||
size_t commandbuffersize; | size_t commandbuffersize; | |||
wchar_t *commandarguments; | wchar_t *commandarguments; | |||
struct command_identifier_node *commandidentifier; | struct command_identifier_node *commandidentifier; | |||
struct command_identifier_node *confirmationkeywordidentifier; | struct command_identifier_node *confirmationkeywordidentifier; | |||
int doprune; | int doprune; | |||
wchar_t *token; | wchar_t *token; | |||
wchar_t *wcsptr; | wchar_t *wcsptr; | |||
wchar_t *wcstolcheck; | wchar_t *wcstolcheck; | |||
long int number; | long int number; | |||
struct status_text *status; | struct status_text *status; | |||
struct prompt_info *prompt; | struct prompt_info *prompt; | |||
int dupesfound; | int dupesfound; | |||
int intresult; | int intresult; | |||
int adjusttopline; | ||||
int toplineoffset = 0; | ||||
int resumecommandinput = 0; | int resumecommandinput = 0; | |||
int index_width; | int index_width; | |||
int timestamp_width; | int timestamp_width; | |||
struct log_info *loginfo; | ||||
noecho(); | noecho(); | |||
cbreak(); | cbreak(); | |||
halfdelay(5); | halfdelay(5); | |||
filewin = newwin(LINES - 2, COLS, 0, 0); | filewin = newwin(LINES - 2, COLS, 0, 0); | |||
statuswin = newwin(1, COLS, LINES - 1, 0); | statuswin = newwin(1, COLS, LINES - 1, 0); | |||
promptwin = newwin(1, COLS, LINES - 2, 0); | promptwin = newwin(1, COLS, LINES - 2, 0); | |||
scrollok(filewin, FALSE); | scrollok(filewin, FALSE); | |||
skipping to change at line 887 | skipping to change at line 881 | |||
case COMMAND_HELP: | case COMMAND_HELP: | |||
endwin(); | endwin(); | |||
if (system(HELP_COMMAND_STRING) == -1) | if (system(HELP_COMMAND_STRING) == -1) | |||
format_status_left(status, L"Could not display help text."); | format_status_left(status, L"Could not display help text."); | |||
refresh(); | refresh(); | |||
break; | break; | |||
case COMMAND_PRUNE: | ||||
cmd_prune(groups, totalgroups, commandarguments, &globaldeletionta | ||||
lly, &totalgroups, &cursorgroup, &cursorfile, &topline, logfile, filewin, status | ||||
); | ||||
break; | ||||
case COMMAND_EXIT: /* exit program */ | case COMMAND_EXIT: /* exit program */ | |||
if (totalgroups == 0) | if (totalgroups == 0) | |||
{ | { | |||
doprune = 0; | doprune = 0; | |||
continue; | continue; | |||
} | } | |||
else | else | |||
{ | { | |||
if (globaldeletiontally != 0) | if (globaldeletiontally != 0) | |||
format_prompt(prompt, L"( There are files marked for deletion. Exit without deleting? )"); | format_prompt(prompt, L"( There are files marked for deletion. Exit without deleting? )"); | |||
skipping to change at line 1234 | skipping to change at line 1232 | |||
case KEY_F(3): | case KEY_F(3): | |||
move_to_next_selected_group(&topline, &cursorgroup, &cursorfile, groups, totalgroups, filewin); | move_to_next_selected_group(&topline, &cursorgroup, &cursorfile, groups, totalgroups, filewin); | |||
break; | break; | |||
case KEY_F(2): | case KEY_F(2): | |||
move_to_previous_selected_group(&topline, &cursorgroup, &cursorfile, gro ups, totalgroups, filewin); | move_to_previous_selected_group(&topline, &cursorgroup, &cursorfile, gro ups, totalgroups, filewin); | |||
break; | break; | |||
case KEY_DC: | case KEY_DC: | |||
totaldeleted = 0; | cmd_prune(groups, totalgroups, commandarguments, &globaldeletiontally, & | |||
deletedbytes = 0; | totalgroups, &cursorgroup, &cursorfile, &topline, logfile, filewin, status); | |||
if (logfile != 0) | ||||
loginfo = log_open(logfile, 0); | ||||
else | ||||
loginfo = 0; | ||||
for (g = 0; g < totalgroups; ++g) | ||||
{ | ||||
preservecount = 0; | ||||
deletecount = 0; | ||||
unresolvedcount = 0; | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
{ | ||||
switch (groups[g].files[f].action) | ||||
{ | ||||
case -1: | ||||
++deletecount; | ||||
break; | ||||
case 0: | ||||
++unresolvedcount; | ||||
break; | ||||
case 1: | ||||
++preservecount; | ||||
break; | ||||
} | ||||
} | ||||
if (loginfo) | ||||
log_begin_set(loginfo); | ||||
/* delete files marked for deletion unless no files left undeleted */ | ||||
if (deletecount < groups[g].filecount) | ||||
{ | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
{ | ||||
if (groups[g].files[f].action == -1) | ||||
{ | ||||
if (remove(groups[g].files[f].file->d_name) == 0) | ||||
{ | ||||
set_file_action(&groups[g].files[f], -2, &globaldeletiontally) | ||||
; | ||||
deletedbytes += groups[g].files[f].file->size; | ||||
++totaldeleted; | ||||
if (loginfo) | ||||
log_file_deleted(loginfo, groups[g].files[f].file->d_name); | ||||
} | ||||
} | ||||
} | ||||
if (loginfo) | ||||
{ | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
{ | ||||
if (groups[g].files[f].action >= 0) | ||||
log_file_remaining(loginfo, groups[g].files[f].file->d_name); | ||||
} | ||||
} | ||||
deletecount = 0; | ||||
} | ||||
if (loginfo) | ||||
log_end_set(loginfo); | ||||
/* if no files left unresolved, mark preserved files for delisting */ | ||||
if (unresolvedcount == 0) | ||||
{ | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
if (groups[g].files[f].action == 1) | ||||
set_file_action(&groups[g].files[f], -2, &globaldeletiontally); | ||||
preservecount = 0; | ||||
} | ||||
/* if only one file left unresolved, mark it for delesting */ | ||||
else if (unresolvedcount == 1 && preservecount + deletecount == 0) | ||||
{ | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
if (groups[g].files[f].action == 0) | ||||
set_file_action(&groups[g].files[f], -2, &globaldeletiontally); | ||||
} | ||||
/* delist any files marked for delisting */ | ||||
to = 0; | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
if (groups[g].files[f].action != -2) | ||||
groups[g].files[to++] = groups[g].files[f]; | ||||
groups[g].filecount = to; | ||||
/* reposition cursor, if necessary */ | ||||
if (cursorgroup == g && cursorfile > 0 && cursorfile >= groups[g].file | ||||
count) | ||||
cursorfile = groups[g].filecount - 1; | ||||
} | ||||
if (loginfo != 0) | ||||
log_close(loginfo); | ||||
if (deletedbytes < 1000.0) | ||||
format_status_left(status, L"Deleted %ld files (occupying %.0f bytes). | ||||
", totaldeleted, deletedbytes); | ||||
else if (deletedbytes <= (1000.0 * 1000.0)) | ||||
format_status_left(status, L"Deleted %ld files (occupying %.1f KB).", | ||||
totaldeleted, deletedbytes / 1000.0); | ||||
else if (deletedbytes <= (1000.0 * 1000.0 * 1000.0)) | ||||
format_status_left(status, L"Deleted %ld files (occupying %.1f MB).", | ||||
totaldeleted, deletedbytes / (1000.0 * 1000.0)); | ||||
else | ||||
format_status_left(status, L"Deleted %ld files (occupying %.1f GB).", | ||||
totaldeleted, deletedbytes / (1000.0 * 1000.0 * 1000.0)); | ||||
/* delist empty groups */ | ||||
to = 0; | ||||
for (g = 0; g < totalgroups; ++g) | ||||
{ | ||||
if (groups[g].filecount > 0) | ||||
{ | ||||
groups[to] = groups[g]; | ||||
/* reposition cursor, if necessary */ | ||||
if (to == cursorgroup && to != g) | ||||
cursorfile = 0; | ||||
++to; | ||||
} | ||||
else | ||||
{ | ||||
free(groups[g].files); | ||||
} | ||||
} | ||||
totalgroups = to; | ||||
/* reposition cursor, if necessary */ | ||||
if (cursorgroup >= totalgroups) | ||||
{ | ||||
cursorgroup = totalgroups - 1; | ||||
cursorfile = 0; | ||||
} | ||||
/* recalculate line boundaries */ | ||||
adjusttopline = 1; | ||||
toplineoffset = 0; | ||||
groupfirstline = 0; | ||||
for (g = 0; g < totalgroups; ++g) | ||||
{ | ||||
if (adjusttopline && groups[g].endline >= topline) | ||||
toplineoffset = groups[g].endline - topline; | ||||
groups[g].startline = groupfirstline; | ||||
groups[g].endline = groupfirstline + 2; | ||||
for (f = 0; f < groups[g].filecount; ++f) | ||||
groups[g].endline += filerowcount(groups[g].files[f].file, COLS, gro | ||||
ups[g].filecount); | ||||
if (adjusttopline && toplineoffset > 0) | ||||
{ | ||||
topline = groups[g].endline - toplineoffset; | ||||
if (topline < 0) | ||||
topline = 0; | ||||
adjusttopline = 0; | ||||
} | ||||
groupfirstline = groups[g].endline + 1; | ||||
} | ||||
if (totalgroups > 0 && groups[totalgroups-1].endline <= topline) | ||||
{ | ||||
topline = groups[totalgroups-1].endline - getmaxy(filewin) + 1; | ||||
if (topline < 0) | ||||
topline = 0; | ||||
} | ||||
break; | break; | |||
case KEY_RESIZE: | case KEY_RESIZE: | |||
/* resize windows */ | /* resize windows */ | |||
wresize(filewin, LINES - 2, COLS); | wresize(filewin, LINES - 2, COLS); | |||
wresize(statuswin, 1, COLS); | wresize(statuswin, 1, COLS); | |||
wresize(promptwin, 1, COLS); | wresize(promptwin, 1, COLS); | |||
mvwin(statuswin, LINES - 1, 0); | mvwin(statuswin, LINES - 1, 0); | |||
mvwin(promptwin, LINES - 2, 0); | mvwin(promptwin, LINES - 2, 0); | |||
End of changes. 7 change blocks. | ||||
189 lines changed or deleted | 8 lines changed or added |