diff -r -u poldek-0.18.3/vfile/vfile.h poldek-0.18.3-patrys/vfile/vfile.h --- poldek-0.18.3/vfile/vfile.h 2004-03-21 13:58:18.172520008 +0100 +++ poldek-0.18.3-patrys/vfile/vfile.h 2004-03-21 13:11:43.209418984 +0100 @@ -20,6 +20,8 @@ #include #include +#include + extern int *vfile_verbose; extern const char *vfile_anonftp_passwd; extern void (*vfile_msg_fn)(const char *fmt, ...); @@ -166,6 +168,7 @@ int is_tty; int prev_n; int prev_perc; + time_t time_base; }; void vfile_progress_init(struct vf_progress_bar *bar); diff -r -u poldek-0.18.3/vfile/vfprogress.c poldek-0.18.3-patrys/vfile/vfprogress.c --- poldek-0.18.3/vfile/vfprogress.c 2002-11-11 22:22:10.000000000 +0100 +++ poldek-0.18.3-patrys/vfile/vfprogress.c 2004-03-21 13:55:53.242552712 +0100 @@ -27,7 +27,7 @@ #define VFILE_INTERNAL #include "vfile.h" -#define PROGRESSBAR_WIDTH 50 +#define PROGRESSBAR_WIDTH 30 void vfile_progress_init(struct vf_progress_bar *bar) { @@ -65,8 +65,9 @@ char line[256], outline[256], fmt[40]; float frac, percent; long n; - - + time_t current_time; + float transfer_rate = 0.0; + float eta = 0.0; if (bar->state == VF_PROGRESS_DISABLED) return; @@ -87,7 +88,7 @@ return; } } - + bar->time_base = time(NULL); bar->state = VF_PROGRESS_RUNNING; } @@ -130,18 +131,30 @@ } } else { - char unit_line[23], amount_str[16], total_str[16]; + char unit_line[43], amount_str[16], total_str[16]; int nn, unit_n; + + current_time = time(NULL); + if (current_time != bar->time_base) + { + transfer_rate = amount / (current_time - bar->time_base) / 1024.0; + } + if (transfer_rate > 0) + { + eta = (total - amount) / (transfer_rate * 1024); + } nbytes2str(total_str, sizeof(total_str), total); nbytes2str(amount_str, sizeof(amount_str), amount); if (total == amount) - nn = n_snprintf(unit_line, sizeof(unit_line), "[%s]", total_str); + nn = n_snprintf(unit_line, sizeof(unit_line), "[%s] [%.1fK/s]", + total_str, transfer_rate); else - nn = n_snprintf(unit_line, sizeof(unit_line), "[%s of %s]", - amount_str, total_str); + nn = n_snprintf(unit_line, sizeof(unit_line), "[%s of %s] [%.1fK/s] [%dm%s%ds]", + amount_str, total_str, transfer_rate, (int)eta / 60, + ((int)eta % 60 < 10 ? "0" : ""), (int)eta % 60); unit_n = sizeof(unit_line) - nn - 1; if (unit_n > 0)