From c9f35cfcad1112803a3b09ce5530a2d7752115ee Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 17 Jun 2012 10:44:01 +0000 Subject: -fix #2354 --- src/fs/gnunet-download.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/fs/gnunet-download.c') 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"), -- cgit v1.2.3