From: Nishi Date: Mon, 7 Oct 2024 02:59:31 +0000 (+0000) Subject: show rate X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=403232deac723dc0395e7600c5b1ff1897007696;p=reisen.git show rate git-svn-id: file:///raid/svn-personal/reisen/trunk@8 c77b849d-6a5c-934c-a956-7b968ca1e197 --- diff --git a/Tool/main.c b/Tool/main.c index 29e3f35..ef1df19 100644 --- a/Tool/main.c +++ b/Tool/main.c @@ -76,6 +76,7 @@ int scan(FILE* f, const char* base, const char* pref){ free(pt); }else{ z_stream strm; + struct stat s; FILE* src = fopen(path, "rb"); unsigned char in[COMPRESS]; unsigned char out[COMPRESS]; @@ -85,6 +86,8 @@ int scan(FILE* f, const char* base, const char* pref){ int i; char* pt; + stat(path, &s); + pt = malloc(1 + strlen(pref) + 1 + strlen(d->d_name)); strcpy(pt, pref); pt[strlen(pref)] = '/'; @@ -121,7 +124,7 @@ int scan(FILE* f, const char* base, const char* pref){ }while(strm.avail_out == 0); }while(flush != Z_FINISH); - printf("done, %lu bytes\n", (unsigned long)written); + printf("done, %lu bytes, %d%%\n", (unsigned long)written, (int)(((double)written / s.st_size) * 100)); total += strlen(pt) + 1 + 5 + written;