Skip to content

Commit

Permalink
make progress display include a gauge (#81)
Browse files Browse the repository at this point in the history
* make progress display include a gauge

* Update hdl_dump.c

* Update hdl_dump.c

* Update hdl_dump.c

* Update hdl_dump.c
  • Loading branch information
israpps authored Jun 6, 2024
1 parent fd285d0 commit 32c296c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions hdl_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,14 +1442,26 @@ handle_sigint(/*@unused@*/ int signo)
static int
progress_cb(progress_t *pgs, /*@unused@*/ void *data)
{
int barWidth = 70, pos, i = 0;
static time_t last_flush = 0;
time_t now = time(NULL);

if (pgs->remaining != -1)
if (pgs->remaining != -1) {
fprintf(stdout, "[");
pos = barWidth * (pgs->pc_completed);
for (i = 0; i < barWidth; ++i) {
if (i < pos)
fprintf(stdout, "=");
else if (i == pos)
fprintf(stdout, ">");
else
fprintf(stdout, " ");
}
fprintf(stdout,
"%3d%%, %s remaining, %.2f MB/sec \r",
"] %3d%%, %s remaining, %.2f MB/sec \r",
pgs->pc_completed, pgs->remaining_text,
(double)pgs->curr_bps / (1024.0 * 1024.0));
}
else
fprintf(stdout, "%3d%%\r", pgs->pc_completed);

Expand Down

0 comments on commit 32c296c

Please sign in to comment.