diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2015-08-31 12:22:14 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2015-08-31 19:13:39 +0000 |
commit | 3a160e754eaa27be157f463c42ecea045906516f (patch) | |
tree | 9eb5831e0d102a672a28c4184742e2af17a006fa /third_party/ijar/zip_main.cc | |
parent | 7ace50057756b7d2fcb7a11e1ef2375704f02d06 (diff) |
Add support for compression in //third_party/ijar:zipper
Add the 'C' flag to //third_party/ijar:zipper to try to compress
files using the DEFLATE algorithm. To avoid regression, creation
of uncompressed ZIP files is still the default.
--
Change-Id: I8ad7182d8f6f152abd56ae472a406cbb8d39fb64
Reviewed-on: https://bazel-review.googlesource.com/#/c/1821/
MOS_MIGRATED_REVID=101925953
Diffstat (limited to 'third_party/ijar/zip_main.cc')
-rw-r--r-- | third_party/ijar/zip_main.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc index aeda2370e2..6c2a974397 100644 --- a/third_party/ijar/zip_main.cc +++ b/third_party/ijar/zip_main.cc @@ -177,7 +177,8 @@ int extract(char *zipfile, bool verbose, bool extract) { } // Execute the create operation -int create(char *zipfile, char **files, bool flatten, bool verbose) { +int create(char *zipfile, char **files, bool flatten, bool verbose, + bool compress) { struct stat statst; u8 size = ZipBuilder::EstimateSize(files); if (size == 0) { @@ -236,7 +237,7 @@ int create(char *zipfile, char **files, bool flatten, bool verbose) { } memcpy(buffer, data, statst.st_size); munmap(data, statst.st_size); - builder->FinishFile(statst.st_size); + builder->FinishFile(statst.st_size, compress); } } if (builder->Finish() < 0) { @@ -252,11 +253,13 @@ int create(char *zipfile, char **files, bool flatten, bool verbose) { // main method // static void usage(char *progname) { - fprintf(stderr, "Usage: %s [vxc[f]] x.zip [file1...filen]\n", progname); + fprintf(stderr, "Usage: %s [vxc[fC]] x.zip [file1...filen]\n", progname); fprintf(stderr, " v verbose - list all file in x.zip\n"); fprintf(stderr, " x extract - extract file in x.zip in current directory\n"); fprintf(stderr, " c create - add files to x.zip\n"); fprintf(stderr, " f flatten - flatten files to use with create operation\n"); + fprintf(stderr, + " C compress - compress files when using the create operation\n"); fprintf(stderr, "x and c cannot be used in the same command-line.\n"); exit(1); } @@ -265,6 +268,7 @@ int main(int argc, char **argv) { bool extract = false; bool verbose = false; bool create = false; + bool compress = false; bool flatten = false; if (argc < 3) { @@ -285,6 +289,9 @@ int main(int argc, char **argv) { case 'f': flatten = true; break; + case 'C': + compress = true; + break; default: usage(argv[0]); } @@ -294,7 +301,7 @@ int main(int argc, char **argv) { usage(argv[0]); } // Create a zip - return devtools_ijar::create(argv[2], argv+3, flatten, verbose); + return devtools_ijar::create(argv[2], argv + 3, flatten, verbose, compress); } else { if (flatten) { usage(argv[0]); |