aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar/zip_main.cc
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2016-12-01 13:16:13 +0000
committerGravatar Irina Iancu <elenairina@google.com>2016-12-01 13:31:53 +0000
commit8d6da00ff0c84d623ccdde7232e0514690d95269 (patch)
treef63aba37d6950d8847964dc0702b4d0dea812fd7 /third_party/ijar/zip_main.cc
parent645dbc4e24f3c5b08cf4701906f4a1e54db3583b (diff)
Ijar: extract file writing logic to platform_utils
This change takes us closer to compiling ijar, thus Bazel, with MSVC. Also update the StatFile method added by unknown commit to report any errors. See https://github.com/bazelbuild/bazel/issues/2157 See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140719249
Diffstat (limited to 'third_party/ijar/zip_main.cc')
-rw-r--r--third_party/ijar/zip_main.cc21
1 files changed, 2 insertions, 19 deletions
diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc
index 351faba616..4347f018ed 100644
--- a/third_party/ijar/zip_main.cc
+++ b/third_party/ijar/zip_main.cc
@@ -37,13 +37,6 @@
namespace devtools_ijar {
-#define SYSCALL(expr) do { \
- if ((expr) < 0) { \
- perror(#expr); \
- abort(); \
- } \
- } while (0)
-
//
// A ZipExtractorProcessor that extract files in the ZIP file.
//
@@ -142,20 +135,12 @@ void UnzipProcessor::Process(const char* filename, const u4 attr,
}
if (extract_) {
char path[PATH_MAX];
- int fd;
concat_path(path, PATH_MAX, output_root_, filename);
// Directories created must have executable bit set and be owner writeable.
// Otherwise, we cannot write or create any file inside.
mkdirs(path, perm | S_IWUSR | S_IXUSR);
- if (!isdir) {
- fd = open(path, O_CREAT | O_WRONLY, perm);
- if (fd < 0) {
- fprintf(stderr, "Cannot open file %s for writing: %s\n",
- path, strerror(errno));
- abort();
- }
- SYSCALL(write(fd, data, size));
- SYSCALL(close(fd));
+ if (!isdir && !write_file(path, perm, data, size)) {
+ abort();
}
}
}
@@ -230,7 +215,6 @@ int add_file(std::unique_ptr<ZipBuilder> const &builder, char *file,
file_stat.file_mode = 0666;
if (file != NULL) {
if (!stat_file(file, &file_stat)) {
- fprintf(stderr, "Cannot stat file %s: %s.\n", file, strerror(errno));
return -1;
}
}
@@ -293,7 +277,6 @@ int add_file(std::unique_ptr<ZipBuilder> const &builder, char *file,
char **read_filelist(char *filename) {
Stat file_stat;
if (!stat_file(filename, &file_stat)) {
- fprintf(stderr, "Cannot stat file %s: %s.\n", filename, strerror(errno));
return NULL;
}