Skip to content

Commit 32c296c

Browse files
authored
make progress display include a gauge (#81)
* make progress display include a gauge * Update hdl_dump.c * Update hdl_dump.c * Update hdl_dump.c * Update hdl_dump.c
1 parent fd285d0 commit 32c296c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

hdl_dump.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,26 @@ handle_sigint(/*@unused@*/ int signo)
14421442
static int
14431443
progress_cb(progress_t *pgs, /*@unused@*/ void *data)
14441444
{
1445+
int barWidth = 70, pos, i = 0;
14451446
static time_t last_flush = 0;
14461447
time_t now = time(NULL);
14471448

1448-
if (pgs->remaining != -1)
1449+
if (pgs->remaining != -1) {
1450+
fprintf(stdout, "[");
1451+
pos = barWidth * (pgs->pc_completed);
1452+
for (i = 0; i < barWidth; ++i) {
1453+
if (i < pos)
1454+
fprintf(stdout, "=");
1455+
else if (i == pos)
1456+
fprintf(stdout, ">");
1457+
else
1458+
fprintf(stdout, " ");
1459+
}
14491460
fprintf(stdout,
1450-
"%3d%%, %s remaining, %.2f MB/sec \r",
1461+
"] %3d%%, %s remaining, %.2f MB/sec \r",
14511462
pgs->pc_completed, pgs->remaining_text,
14521463
(double)pgs->curr_bps / (1024.0 * 1024.0));
1464+
}
14531465
else
14541466
fprintf(stdout, "%3d%%\r", pgs->pc_completed);
14551467

0 commit comments

Comments
 (0)