forked from h2oai/jdupes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress.c
33 lines (28 loc) · 985 Bytes
/
progress.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* jdupes progress indicator
see jdupes.c for licensing information */
#include <stdio.h>
#include <inttypes.h>
#include "jdupes.h"
#include "likely_unlikely.h"
void update_phase1_progress(const char * const restrict type)
{
fprintf(stderr, "\rScanning: %" PRIuMAX " files, %" PRIuMAX " %s (in %u specified)",
progress, item_progress, type, user_item_count);
// fflush(stderr);
}
/* Update progress indicator if requested */
void update_phase2_progress(const char * const restrict msg, const int file_percent)
{
static int did_fpct = 0;
fprintf(stderr, "\rProgress [%" PRIuMAX "/%" PRIuMAX ", %" PRIuMAX " pairs matched] %" PRIuMAX "%%",
progress, filecount, dupecount, (progress * 100) / filecount);
if (file_percent > -1 && msg != NULL) {
fprintf(stderr, " (%s: %d%%) ", msg, file_percent);
did_fpct = 1;
} else if (did_fpct != 0) {
fprintf(stderr, " ");
did_fpct = 0;
}
// fflush(stderr);
return;
}