List Archive
Thread
-
Failed to unzip file by zip_fdopen with the error ,
Qifei Wang
(2019/09/07 01:03:25)
- Re: Failed to unzip file by zip_fdopen with the er, Qifei Wang (2019/09/07 02:01:02)
-
Re: Failed to unzip file by zip_fdopen with the er,
Thomas Klausner
(2019/09/07 20:52:49)
-
Re: Failed to unzip file by zip_fdopen with the er,
Qifei Wang
(2019/09/08 01:09:37)
- Re: Failed to unzip file by zip_fdopen with the er, Thomas Klausner (2019/09/08 07:10:36)
-
Re: Failed to unzip file by zip_fdopen with the er,
Qifei Wang
(2019/09/08 01:09:37)
Message
More context: This code snippet works well in desktop unit test. The bug happens when I test it on Android. The file is downloaded from the server. The `src->supports` is recorded as 16575 while `needed_support_read` is set to 207 at the runtime which causes the bug.
Cheers,
Qifei Wang
Qifei Wang
On Fri, Sep 6, 2019 at 6:03 PM Qifei Wang <qfwang%google.com@localhost> wrote:
Hi there,I am trying to unzip a zip file from file descriptor by the following code snippet. It reports the error ZIP_ER_OPNOTSUPP. The file descriptor is valid. The error seems reported by zip_open_from_source() method. See https://github.com/nih-at/libzip/blob/master/lib/zip_open.c#L106. Any idea about this?zip_t* archive = zip_fdopen(file_descriptor, O_RDONLY, &errorp);
if (!archive) {
// Error report here.
}
zip_int64_t num = zip_get_num_entries(archive, ZIP_FL_UNCHANGED);
for (zip_uint64_t i = 0; i < num; ++i) {
const char* name = zip_get_name(archive, i, ZIP_FL_ENC_GUESS);
zip_file_t* zip_file = zip_fopen(archive, name, ZIP_FL_ENC_GUESS);
zip_stat_t zip_file_stat;
zip_stat_init(&zip_file_stat);
zip_stat_index(archive, /*index=*/i, /*flags=*/0, &zip_file_stat);
auto buf = absl::make_unique<char[]>(zip_file_stat.size);
zip_int64_t size_read = zip_fread(zip_file, buf.get(), zip_file_stat.size);
if (size_read == -1) {
// Error handling.
}
const std::string output_filename = file::JoinPath(dir, name);
// Extract to output_filename.
int zip_file_close_result = zip_fclose(zip_file);
if (zip_file_close_result != 0) {
// Error handling.
}
}
if (zip_close(archive) != 0) {
// Error handling.
}Cheers,
Qifei Wang
Made by MHonArc.