"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ncurses-commands.c" between
fdupes-2.0.0.tar.gz and fdupes-2.1.0.tar.gz

About: FDUPES finds duplicate files in a given set of directories.

ncurses-commands.c  (fdupes-2.0.0):ncurses-commands.c  (fdupes-2.1.0)
skipping to change at line 27 skipping to change at line 27
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "config.h" #include "config.h"
#include "ncurses-status.h" #include "ncurses-status.h"
#include "ncurses-commands.h" #include "ncurses-commands.h"
#include "wcs.h" #include "wcs.h"
#include "mbstowcs_escape_invalid.h" #include "mbstowcs_escape_invalid.h"
#include "log.h"
#include <wchar.h> #include <wchar.h>
#include <pcre2.h> #include <pcre2.h>
void set_file_action(struct groupfile *file, int new_action, size_t *deletion_ta lly); void set_file_action(struct groupfile *file, int new_action, size_t *deletion_ta lly);
struct command_map command_list[] = { struct command_map command_list[] = {
{L"sel", COMMAND_SELECT_CONTAINING}, {L"sel", COMMAND_SELECT_CONTAINING},
{L"selb", COMMAND_SELECT_BEGINNING}, {L"selb", COMMAND_SELECT_BEGINNING},
{L"sele", COMMAND_SELECT_ENDING}, {L"sele", COMMAND_SELECT_ENDING},
{L"selm", COMMAND_SELECT_MATCHING}, {L"selm", COMMAND_SELECT_MATCHING},
{L"selr", COMMAND_SELECT_REGEX}, {L"selr", COMMAND_SELECT_REGEX},
{L"dsel", COMMAND_CLEAR_SELECTIONS_CONTAINING}, {L"dsel", COMMAND_CLEAR_SELECTIONS_CONTAINING},
{L"dselb", COMMAND_CLEAR_SELECTIONS_BEGINNING}, {L"dselb", COMMAND_CLEAR_SELECTIONS_BEGINNING},
{L"dsele", COMMAND_CLEAR_SELECTIONS_ENDING}, {L"dsele", COMMAND_CLEAR_SELECTIONS_ENDING},
{L"dselm", COMMAND_CLEAR_SELECTIONS_MATCHING}, {L"dselm", COMMAND_CLEAR_SELECTIONS_MATCHING},
{L"dselr", COMMAND_CLEAR_SELECTIONS_REGEX}, {L"dselr", COMMAND_CLEAR_SELECTIONS_REGEX},
{L"cs", COMMAND_CLEAR_ALL_SELECTIONS}, {L"csel", COMMAND_CLEAR_ALL_SELECTIONS},
{L"igs", COMMAND_INVERT_GROUP_SELECTIONS}, {L"isel", COMMAND_INVERT_GROUP_SELECTIONS},
{L"ks", COMMAND_KEEP_SELECTED}, {L"ks", COMMAND_KEEP_SELECTED},
{L"ds", COMMAND_DELETE_SELECTED}, {L"ds", COMMAND_DELETE_SELECTED},
{L"rs", COMMAND_RESET_SELECTED}, {L"rs", COMMAND_RESET_SELECTED},
{L"rg", COMMAND_RESET_GROUP}, {L"rg", COMMAND_RESET_GROUP},
{L"all", COMMAND_PRESERVE_ALL}, {L"all", COMMAND_PRESERVE_ALL},
{L"goto", COMMAND_GOTO_SET}, {L"goto", COMMAND_GOTO_SET},
{L"prune", COMMAND_PRUNE},
{L"exit", COMMAND_EXIT}, {L"exit", COMMAND_EXIT},
{L"quit", COMMAND_EXIT}, {L"quit", COMMAND_EXIT},
{L"help", COMMAND_HELP}, {L"help", COMMAND_HELP},
{0, COMMAND_UNDEFINED} {0, COMMAND_UNDEFINED}
}; };
struct command_map confirmation_keyword_list[] = { struct command_map confirmation_keyword_list[] = {
{L"yes", COMMAND_YES}, {L"yes", COMMAND_YES},
{L"no", COMMAND_NO}, {L"no", COMMAND_NO},
{0, COMMAND_UNDEFINED} {0, COMMAND_UNDEFINED}
skipping to change at line 572 skipping to change at line 574
int f; int f;
for (g = 0; g < groupcount; ++g) for (g = 0; g < groupcount; ++g)
{ {
for (f = 0; f < groups[g].filecount; ++f) for (f = 0; f < groups[g].filecount; ++f)
groups[g].files[f].selected = 0; groups[g].files[f].selected = 0;
groups[g].selected = 0; groups[g].selected = 0;
} }
format_status_left(status, L"Cleared all selections."); if (status)
format_status_left(status, L"Cleared all selections.");
return 1; return 1;
} }
/* invert selections within selected groups */ /* invert selections within selected groups */
int cmd_invert_group_selections(struct filegroup *groups, int groupcount, wchar_ t *commandarguments, struct status_text *status) int cmd_invert_group_selections(struct filegroup *groups, int groupcount, wchar_ t *commandarguments, struct status_text *status)
{ {
int g; int g;
int f; int f;
int selectedcount = 0; int selectedcount = 0;
skipping to change at line 677 skipping to change at line 680
set_file_action(&groups[g].files[f], 0, deletiontally); set_file_action(&groups[g].files[f], 0, deletiontally);
++resetfilecount; ++resetfilecount;
} }
} }
} }
format_status_left(status, L"Unmarked %d files.", resetfilecount); format_status_left(status, L"Unmarked %d files.", resetfilecount);
return 1; return 1;
} }
int filerowcount(file_t *file, const int columns, int group_file_count);
/* delete files tagged for deletion, delist sets with no untagged files */
int cmd_prune(struct filegroup *groups, int groupcount, wchar_t *commandargument
s, size_t *deletiontally, int *totalgroups, int *cursorgroup, int *cursorfile, i
nt *topline, char *logfile, WINDOW *filewin, struct status_text *status)
{
int deletecount;
int preservecount;
int unresolvedcount;
int totaldeleted = 0;
double deletedbytes = 0;
struct log_info *loginfo;
int g;
int f;
int to;
int adjusttopline;
int toplineoffset;
int groupfirstline;
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, deletiontally);
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, deletiontally);
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, deletiontally);
}
/* 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].filecou
nt)
*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).", tot
aldeleted, deletedbytes);
else if (deletedbytes <= (1000.0 * 1000.0))
format_status_left(status, L"Deleted %ld files (occupying %.1f KB).", totald
eleted, deletedbytes / 1000.0);
else if (deletedbytes <= (1000.0 * 1000.0 * 1000.0))
format_status_left(status, L"Deleted %ld files (occupying %.1f MB).", totald
eleted, deletedbytes / (1000.0 * 1000.0));
else
format_status_left(status, L"Deleted %ld files (occupying %.1f GB).", totald
eleted, 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, groups[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;
}
cmd_clear_all_selections(groups, *totalgroups, commandarguments, 0);
}
 End of changes. 5 change blocks. 
3 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)