X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=finddup.c;h=5167a5956bbaeff068d489e11b1aaa96b25f66bf;hb=ba0a93e5d70103f2aee5395eac74b05792aaa3a8;hp=6b141428ecd77e25bd37a258456d0eb12ed666c7;hpb=87d05f158cb6c552c1de528628bbf10c65e0edb6;p=finddup.git diff --git a/finddup.c b/finddup.c index 6b14142..5167a59 100644 --- a/finddup.c +++ b/finddup.c @@ -403,8 +403,8 @@ void print_progress(struct progress_state *state) { if(state->bar_width <= 0 || position != state->last_position) { if(!ioctl (STDERR_FILENO, TIOCGWINSZ, (char *) &win)) { /* Something weird is going on if the previous test is wrong */ - if(win.ws_col >= PROGRESS_BUFFER_SIZE) { - state->bar_width = PROGRESS_BUFFER_SIZE - 8; + if(win.ws_col >= PROGRESS_BUFFER_SIZE - 3) { + state->bar_width = PROGRESS_BUFFER_SIZE - 10; } else { state->bar_width = win.ws_col - 7; } @@ -417,7 +417,9 @@ void print_progress(struct progress_state *state) { for(; k < state->bar_width; k++) { *(s++) = '-'; } - sprintf(s, " [%3d%%]\r", + + /* We need four % because of the fprintf that follows */ + sprintf(s, " [%3d%%%%]\r", (100 * state->value) / (state->nb_values - 1)); fprintf(stderr, buffer); @@ -440,13 +442,18 @@ void start(const char *dirname1, const char *dirname2) { not_in = 0; if(show_progress) { - fprintf(stderr, "Scanning %s ... ", dirname1); + fprintf(stderr, "Scanning '%s' ... ", dirname1); } list1 = scan_directory(0, dirname1); list1_length = file_list_length(list1); + if(show_progress) { + fprintf(stderr, "done (%d file%s).\n", + list1_length, (list1_length > 1 ? "s" : "")); + } + if(dirname2) { if(strncmp(dirname2, "not:", 4) == 0) { not_in = 1; @@ -457,25 +464,20 @@ void start(const char *dirname1, const char *dirname2) { dirname2 += 4; } if(show_progress) { - fprintf(stderr, "%s ... ", dirname2); + fprintf(stderr, "Scanning '%s' ... ", dirname2); } list2 = scan_directory(0, dirname2); + if(show_progress) { + list2_length = file_list_length(list2); + fprintf(stderr, "done (%d file%s).\n", + list2_length, (list2_length > 1 ? "s" : "")); + } } else { list2 = list1; } if(show_progress) { - fprintf(stderr, "done.\n"); - fprintf(stderr, - "%s: %d file%s.\n", - dirname1, list1_length, (list1_length > 1 ? "s" : "")); - if(dirname2) { - list2_length = file_list_length(list2); - fprintf(stderr, - "%s: %d file%s.\n", - dirname2, list2_length, (list2_length > 1 ? "s" : "")); - } - fprintf(stderr, "Now looking for identical files.\n"); + fprintf(stderr, "Now looking for identical files (this may take a while).\n"); } nb_groups = 0;