Add -S option to print out summary after compression has been

completed.

MFC after: 	2 weeks
This commit is contained in:
sobomax 2016-03-10 21:36:24 +00:00
parent 03f8f8e396
commit 773a64f003
2 changed files with 12 additions and 3 deletions

View File

@ -118,6 +118,9 @@ detects identical blocks in the input and replaces each subsequent occurence
of such block with pointer to the very first one in the output.
Setting this option results is moderate decrease of compressed image size,
typically around 3-5% of a final size of the compressed image.
.It Fl S
Print summary about the compression ratio as well as output
file size after file has been processed.
.El
.Sh NOTES
The compression ratio largely depends on the cluster size used.

View File

@ -90,6 +90,7 @@ int main(int argc, char **argv)
char *iname, *oname, *obuf, *ibuf;
uint64_t *toc;
int fdr, fdw, i, opt, verbose, no_zcomp, tmp, en_dedup;
int summary;
struct iovec iov[2];
struct stat sb;
uint32_t destlen;
@ -104,9 +105,10 @@ int main(int argc, char **argv)
verbose = 0;
no_zcomp = 0;
en_dedup = 0;
summary = 0;
handler = &uzip_fmt;
while((opt = getopt(argc, argv, "o:s:vZdL")) != -1) {
while((opt = getopt(argc, argv, "o:s:vZdLS")) != -1) {
switch(opt) {
case 'o':
oname = optarg;
@ -138,6 +140,10 @@ int main(int argc, char **argv)
handler = &ulzma_fmt;
break;
case 'S':
summary = 1;
break;
default:
usage();
/* Not reached */
@ -294,7 +300,7 @@ int main(int argc, char **argv)
}
close(fdr);
if (verbose != 0)
if (verbose != 0 || summary != 0)
fprintf(stderr, "compressed data to %ju bytes, saved %lld "
"bytes, %.2f%% decrease.\n", offset,
(long long)(sb.st_size - offset),
@ -337,7 +343,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: mkuzip [-vZdL] [-o outfile] [-s cluster_size] "
fprintf(stderr, "usage: mkuzip [-vZdLS] [-o outfile] [-s cluster_size] "
"infile\n");
exit(1);
}