summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-02-19 15:28:31 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-02-19 18:51:03 +0100
commit74c70b398058e5d57854d320d2920d145b842bbe (patch)
treeda94019f418d31983fd40652f6143b1a92db5075 /lib
parent16babe2c7f7c21a7a007486c87021bc4dce519a8 (diff)
downloadbarebox-74c70b398058e5d57854d320d2920d145b842bbe.tar.gz
barebox-74c70b398058e5d57854d320d2920d145b842bbe.tar.xz
copy_file: limit progress bar to sensible limits
When copying in verbose mode from a tftp server we might not know the size of the file being transfered. In this case print one progress item per 16k instead of one for each single byte. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/copy_file.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/copy_file.c b/lib/copy_file.c
index 967806c3b0..484b2ca725 100644
--- a/lib/copy_file.c
+++ b/lib/copy_file.c
@@ -21,6 +21,7 @@ int copy_file(const char *src, const char *dst, int verbose)
int ret = 1;
void *buf;
int total = 0;
+ struct stat statbuf;
rw_buf = xmalloc(RW_BUF_SIZE);
@@ -37,8 +38,6 @@ int copy_file(const char *src, const char *dst, int verbose)
}
if (verbose) {
- struct stat statbuf;
-
if (stat(src, &statbuf) < 0)
statbuf.st_size = 0;
@@ -67,7 +66,7 @@ int copy_file(const char *src, const char *dst, int verbose)
}
if (verbose)
- show_progress(total);
+ show_progress(statbuf.st_size ? total : total / 16384);
}
ret = 0;