]> git.pld-linux.org Git - packages/poldek.git/blame - poldek-progress.patch
- added new progress bar
[packages/poldek.git] / poldek-progress.patch
CommitLineData
96a4a270 1diff -r -u poldek-0.18.3/vfile/vfile.h poldek-0.18.3-patrys/vfile/vfile.h
2--- poldek-0.18.3/vfile/vfile.h 2004-03-21 13:58:18.172520008 +0100
3+++ poldek-0.18.3-patrys/vfile/vfile.h 2004-03-21 13:11:43.209418984 +0100
4@@ -20,6 +20,8 @@
5 #include <zlib.h>
6 #include <trurl/narray.h>
7
8+#include <time.h>
9+
10 extern int *vfile_verbose;
11 extern const char *vfile_anonftp_passwd;
12 extern void (*vfile_msg_fn)(const char *fmt, ...);
13@@ -166,6 +168,7 @@
14 int is_tty;
15 int prev_n;
16 int prev_perc;
17+ time_t time_base;
18 };
19
20 void vfile_progress_init(struct vf_progress_bar *bar);
21diff -r -u poldek-0.18.3/vfile/vfprogress.c poldek-0.18.3-patrys/vfile/vfprogress.c
22--- poldek-0.18.3/vfile/vfprogress.c 2002-11-11 22:22:10.000000000 +0100
23+++ poldek-0.18.3-patrys/vfile/vfprogress.c 2004-03-21 13:55:53.242552712 +0100
24@@ -27,7 +27,7 @@
25 #define VFILE_INTERNAL
26 #include "vfile.h"
27
28-#define PROGRESSBAR_WIDTH 50
29+#define PROGRESSBAR_WIDTH 30
30
31 void vfile_progress_init(struct vf_progress_bar *bar)
32 {
33@@ -65,8 +65,9 @@
34 char line[256], outline[256], fmt[40];
35 float frac, percent;
36 long n;
37-
38-
39+ time_t current_time;
40+ float transfer_rate = 0.0;
41+ float eta = 0.0;
42
43 if (bar->state == VF_PROGRESS_DISABLED)
44 return;
45@@ -87,7 +88,7 @@
46 return;
47 }
48 }
49-
50+ bar->time_base = time(NULL);
51 bar->state = VF_PROGRESS_RUNNING;
52 }
53
54@@ -130,18 +131,30 @@
55 }
56
57 } else {
58- char unit_line[23], amount_str[16], total_str[16];
59+ char unit_line[43], amount_str[16], total_str[16];
60 int nn, unit_n;
61
62+
63+ current_time = time(NULL);
64+ if (current_time != bar->time_base)
65+ {
66+ transfer_rate = amount / (current_time - bar->time_base) / 1024.0;
67+ }
68+ if (transfer_rate > 0)
69+ {
70+ eta = (total - amount) / (transfer_rate * 1024);
71+ }
72
73 nbytes2str(total_str, sizeof(total_str), total);
74 nbytes2str(amount_str, sizeof(amount_str), amount);
75
76 if (total == amount)
77- nn = n_snprintf(unit_line, sizeof(unit_line), "[%s]", total_str);
78+ nn = n_snprintf(unit_line, sizeof(unit_line), "[%s] [%.1fK/s]",
79+ total_str, transfer_rate);
80 else
81- nn = n_snprintf(unit_line, sizeof(unit_line), "[%s of %s]",
82- amount_str, total_str);
83+ nn = n_snprintf(unit_line, sizeof(unit_line), "[%s of %s] [%.1fK/s] [%dm%s%ds]",
84+ amount_str, total_str, transfer_rate, (int)eta / 60,
85+ ((int)eta % 60 < 10 ? "0" : ""), (int)eta % 60);
86
87 unit_n = sizeof(unit_line) - nn - 1;
88 if (unit_n > 0)
This page took 0.030697 seconds and 4 git commands to generate.