summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/imgtool/stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/imgtool/stream.cpp')
-rw-r--r--src/tools/imgtool/stream.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/tools/imgtool/stream.cpp b/src/tools/imgtool/stream.cpp
index 4cc4c9ec2db..b11e7a5e4be 100644
--- a/src/tools/imgtool/stream.cpp
+++ b/src/tools/imgtool/stream.cpp
@@ -104,33 +104,26 @@ static imgtool_stream *stream_open_zip(const char *zipname, const char *subname,
imgfile->imgtype = IMG_MEM;
- zip_file *z = nullptr;
- const zip_file_header *zipent = nullptr;
- zip_file_open(zipname, &z);
+ util::archive_file::ptr z;
+ util::archive_file::open_zip(zipname, z);
if (!z)
- goto error;
+ return nullptr;
- zipent = zip_file_first_file(z);
- while (zipent && subname && strcmp(subname, zipent->filename))
- zipent = zip_file_next_file(z);
- if (!zipent)
- goto error;
+ int zipent = z->first_file();
+ while ((zipent >= 0) && subname && strcmp(subname, z->current_name().c_str()))
+ zipent = z->next_file();
+ if (zipent < 0)
+ return nullptr;
- imgfile->filesize = zipent->uncompressed_length;
- imgfile->buffer = reinterpret_cast<std::uint8_t *>(malloc(zipent->uncompressed_length));
+ imgfile->filesize = z->current_uncompressed_length();
+ imgfile->buffer = reinterpret_cast<std::uint8_t *>(malloc(z->current_uncompressed_length()));
if (!imgfile->buffer)
- goto error;
+ return nullptr;
- if (zip_file_decompress(z, imgfile->buffer, zipent->uncompressed_length))
- goto error;
+ if (z->decompress(imgfile->buffer, z->current_uncompressed_length()) != util::archive_file::error::NONE)
+ return nullptr;
- zip_file_close(z);
return imgfile.release();
-
-error:
- if (z)
- zip_file_close(z);
- return nullptr;
}
@@ -154,7 +147,7 @@ imgtool_stream *stream_open(const char *fname, int read_or_write)
util::core_file::ptr f = nullptr;
auto const filerr = util::core_file::open(fname, write_modes[read_or_write], f);
- if (filerr != FILERR_NONE)
+ if (filerr != osd_file::error::NONE)
{
if (!read_or_write)
{