aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar/zip.cc
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-08-04 13:48:02 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-08-04 15:17:48 +0000
commit43302f42fc6c2bd342cebc50ca53e52da7727cba (patch)
treed2f0d8d357f274af760bd53114df21903dcc3e70 /third_party/ijar/zip.cc
parent20e6e8e3885ede8e68a347ca58ea38c4ec05ccc1 (diff)
zipper now can specify actual path a file is added to
Examples for how to use <zip_path>=<file> syntax: zipper c x.zip a/b/__init__.py= # Add an empty file at a/b/__init__.py zipper c x.zip a/b/main.py=foo/bar/bin.py # Add file foo/bar/bin.py at a/b/main.py -- Change-Id: I3c09dfb31d082f3ca8036e87affc8d99f7e75fe0 Reviewed-on: https://bazel-review.googlesource.com/#/c/4243 MOS_MIGRATED_REVID=129325719
Diffstat (limited to 'third_party/ijar/zip.cc')
-rw-r--r--third_party/ijar/zip.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/third_party/ijar/zip.cc b/third_party/ijar/zip.cc
index a7a406fcbb..a3d8c53831 100644
--- a/third_party/ijar/zip.cc
+++ b/third_party/ijar/zip.cc
@@ -1200,14 +1200,15 @@ ZipBuilder* ZipBuilder::Create(const char* zip_file, u8 estimated_size) {
return result;
}
-u8 ZipBuilder::EstimateSize(char **files) {
+u8 ZipBuilder::EstimateSize(char **files, char **zip_paths, int nb_entries) {
struct stat statst;
// Digital signature field size = 6, End of central directory = 22, Total = 28
u8 size = 28;
// Count the size of all the files in the input to estimate the size of the
// output.
- for (int i = 0; files[i] != NULL; i++) {
- if (stat(files[i], &statst) != 0) {
+ for (int i = 0; i < nb_entries; i++) {
+ statst.st_size = 0;
+ if (files[i] != NULL && stat(files[i], &statst) != 0) {
fprintf(stderr, "File %s does not seem to exist.", files[i]);
return 0;
}
@@ -1220,7 +1221,7 @@ u8 ZipBuilder::EstimateSize(char **files) {
size += 88;
// The filename is stored twice (once in the central directory
// and once in the local file header).
- size += strlen(files[i]) * 2;
+ size += strlen((zip_paths[i] != NULL) ? zip_paths[i] : files[i]) * 2;
}
return size;
}