]> Git repositories of Nishi - reisen.git/commitdiff
show rate
authorNishi <nishi@nishi.boats>
Mon, 7 Oct 2024 02:59:31 +0000 (02:59 +0000)
committerNishi <nishi@nishi.boats>
Mon, 7 Oct 2024 02:59:31 +0000 (02:59 +0000)
git-svn-id: file:///raid/svn-personal/reisen/trunk@8 c77b849d-6a5c-934c-a956-7b968ca1e197

Tool/main.c

index 29e3f350231c9f7daa62b4005846ed6cf7859af3..ef1df1963666fe1d1d10d3fe4870e8604ba9818f 100644 (file)
@@ -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;