From: Christian Grothoff Date: Sun, 17 Jun 2012 10:44:01 +0000 (+0000) Subject: -fix #2354 X-Git-Tag: initial-import-from-subversion-38251~13015 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c9f35cfcad1112803a3b09ce5530a2d7752115ee;p=oweals%2Fgnunet.git -fix #2354 --- diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index bd5b09c0d..aa1da8f3d 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c @@ -74,6 +74,41 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } +/** + * Display progress bar (if tty). + * + * @param x current position in the download + * @param n total size of the download + * @param w desired number of steps in the progress bar + */ +static void +display_bar (unsigned long long x, + unsigned long long n, + unsigned int w) +{ + char buf[w + 20]; + unsigned int p; + unsigned int endeq; + float ratio_complete; + +#ifndef MINGW + if (0 == isatty (1)) + return; +#endif + ratio_complete = x/(float)n; + endeq = ratio_complete * w; + GNUNET_snprintf (buf, sizeof (buf), + "%3d%% [", (int)(ratio_complete*100) ); + for (p=0; pvalue.download.completed, + info->value.download.size, + 60); + } break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: FPRINTF (stderr, _("Error downloading: %s.\n"),