diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-30 05:41:11 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-30 05:41:11 +0200 |
commit | d0bc708cb52693b9ed1dab495e5f99fb8e1122f7 (patch) | |
tree | b123030ef61de00f80e0ba25be85f10a7ae8489f | |
parent | 05965cbb7587f6ba06687a94d040d0ae5933d28a (diff) | |
download | busybox-w32-d0bc708cb52693b9ed1dab495e5f99fb8e1122f7.tar.gz busybox-w32-d0bc708cb52693b9ed1dab495e5f99fb8e1122f7.tar.bz2 busybox-w32-d0bc708cb52693b9ed1dab495e5f99fb8e1122f7.zip |
unpackers: by users' request, print compression percentage if -v and DESKTOP
function old new delta
bbunpack 634 731 +97
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/bbunzip.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index b332eecd6..3735e3282 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -132,7 +132,10 @@ int FAST_FUNC bbunpack(char **argv, | |||
132 | 132 | ||
133 | if (filename) { | 133 | if (filename) { |
134 | char *del = new_name; | 134 | char *del = new_name; |
135 | |||
135 | if (status >= 0) { | 136 | if (status >= 0) { |
137 | unsigned new_name_len; | ||
138 | |||
136 | /* TODO: restore other things? */ | 139 | /* TODO: restore other things? */ |
137 | if (aux.mtime != 0) { | 140 | if (aux.mtime != 0) { |
138 | struct timeval times[2]; | 141 | struct timeval times[2]; |
@@ -146,22 +149,29 @@ int FAST_FUNC bbunpack(char **argv, | |||
146 | utimes(new_name, times); /* ignoring errors */ | 149 | utimes(new_name, times); /* ignoring errors */ |
147 | } | 150 | } |
148 | 151 | ||
149 | /* Delete _compressed_ file */ | 152 | if (ENABLE_DESKTOP) |
153 | new_name_len = strlen(new_name); | ||
154 | /* Restore source filename (unless tgz -> tar case) */ | ||
155 | if (new_name == filename) { | ||
156 | new_name_len = strlen(filename); | ||
157 | filename[new_name_len] = '.'; | ||
158 | } | ||
159 | /* Extreme bloat for gunzip compat */ | ||
160 | /* Some users do want this info... */ | ||
161 | if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE)) { | ||
162 | unsigned percent = status | ||
163 | ? ((uoff_t)stat_buf.st_size * 100u / (unsigned long long)status) | ||
164 | : 0; | ||
165 | fprintf(stderr, "%s: %u%% - replaced with %.*s\n", | ||
166 | filename, | ||
167 | 100u - percent, | ||
168 | new_name_len, new_name | ||
169 | ); | ||
170 | } | ||
171 | /* Delete _source_ file */ | ||
150 | del = filename; | 172 | del = filename; |
151 | /* restore extension (unless tgz -> tar case) */ | ||
152 | if (new_name == filename) | ||
153 | filename[strlen(filename)] = '.'; | ||
154 | } | 173 | } |
155 | xunlink(del); | 174 | xunlink(del); |
156 | |||
157 | #if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */ | ||
158 | /* Extreme bloat for gunzip compat */ | ||
159 | if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) { | ||
160 | fprintf(stderr, "%s: %u%% - replaced with %s\n", | ||
161 | filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name); | ||
162 | } | ||
163 | #endif | ||
164 | |||
165 | free_name: | 175 | free_name: |
166 | if (new_name != filename) | 176 | if (new_name != filename) |
167 | free(new_name); | 177 | free(new_name); |