Skip to content

Commit

Permalink
make progress display include a gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
israpps authored May 23, 2024
1 parent fd285d0 commit d83a3d7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hdl_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,14 +1442,27 @@ handle_sigint(/*@unused@*/ int signo)
static int
progress_cb(progress_t *pgs, /*@unused@*/ void *data)
{
int barWidth = 70;
static time_t last_flush = 0;
time_t now = time(NULL);

if (pgs->remaining != -1)
if (pgs->remaining != -1) {
fprintf(stdout, "[");
int pos = barWidth * (pgs->pc_completed);
for (int 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 d83a3d7

Please sign in to comment.