fix: unzip errcode 900002

Signed-off-by: zhrenqiang <zhangrenqiang@huawei.com>
Change-Id: I7fba4c1c3618eb1a0a7cd8daaf5276ad0f8c96f1
This commit is contained in:
zhrenqiang 2024-11-15 20:28:03 +08:00
parent 235bd80f0a
commit f31a213738
3 changed files with 9 additions and 3 deletions

View File

@ -244,6 +244,10 @@ ErrCode UnzipWithFilterAndWriters(const PlatformFile &srcFile, FilePath &destDir
}
} else {
std::unique_ptr<WriterDelegate> writer = writerFactory(destDir, entryPath);
if (!writer->PrepareOutput()) {
APP_LOGE("PrepareOutput err");
return ERR_ZLIB_DEST_FILE_DISABLED;
}
if (!reader.ExtractCurrentEntry(writer.get(), std::numeric_limits<uint64_t>::max())) {
APP_LOGI("Failed to extract");
return ERR_ZLIB_SRC_FILE_FORMAT_ERROR;

View File

@ -268,6 +268,10 @@ ErrCode UnzipWithFilterAndWriters(const PlatformFile &srcFile, FilePath &destDir
}
} else {
std::unique_ptr<WriterDelegate> writer = writerFactory(destDir, entryPath);
if (!writer->PrepareOutput()) {
APP_LOGE("PrepareOutput err");
return ERR_ZLIB_DEST_FILE_DISABLED;
}
if (!reader.ExtractCurrentEntry(writer.get(), std::numeric_limits<uint64_t>::max())) {
APP_LOGI("Failed to extract");
return ERR_ZLIB_SRC_FILE_FORMAT_ERROR;

View File

@ -191,9 +191,7 @@ bool ZipReader::ExtractCurrentEntry(WriterDelegate *delegate, uint64_t numBytesT
}
const int openResult = unzOpenCurrentFile(zipFile_);
if (openResult != UNZ_OK) {
return false;
}
if (!delegate->PrepareOutput()) {
APP_LOGE("unzOpen err %{public}d", openResult);
return false;
}
auto buf = std::make_unique<char[]>(kZipBufSize);