Skip to content

Commit

Permalink
Add support for minizip-ng 4 API (#1806)
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Smith <brad@comstyle.com>
Co-authored-by: Rémi Achard <remiachard@gmail.com>
Co-authored-by: Doug Walker <doug.walker@autodesk.com>
  • Loading branch information
3 people committed Jul 28, 2023
1 parent f26df74 commit bdc4cd1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/OpenColorIO/OCIOZArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c
std::string configStr = ss.str();

// Write zip to memory stream.
#if MZ_VERSION_BUILD >= 040000
write_mem_stream = mz_stream_mem_create();
#else
mz_stream_mem_create(&write_mem_stream);
#endif
mz_stream_mem_set_grow_size(write_mem_stream, 128 * 1024);
mz_stream_open(write_mem_stream, NULL, MZ_OPEN_MODE_CREATE);

Expand All @@ -237,7 +241,11 @@ void archiveConfig(std::ostream & ostream, const Config & config, const char * c
options.compress_level = ArchiveCompressionLevels::BEST;

// Create the writer handle.
#if MZ_VERSION_BUILD >= 040000
archiver = mz_zip_writer_create();
#else
mz_zip_writer_create(&archiver);
#endif

// Archive options.
// Compression method
Expand Down Expand Up @@ -332,7 +340,11 @@ void ExtractOCIOZArchive(const char * archivePath, const char * destination)
std::string outputDestination = pystring::os::path::normpath(destination);

// Create zip reader.
#if MZ_VERSION_BUILD >= 040000
extracter = mz_zip_reader_create();
#else
mz_zip_reader_create(&extracter);
#endif

MinizipNgHandlerGuard extracterGuard(extracter, false, false);

Expand Down Expand Up @@ -450,7 +462,11 @@ std::vector<uint8_t> getFileStringFromArchiveFile(const std::string & filepath,
std::vector<uint8_t> buffer;

// Create the reader object.
#if MZ_VERSION_BUILD >= 040000
reader = mz_zip_reader_create();
#else
mz_zip_reader_create(&reader);
#endif

MinizipNgHandlerGuard extracterGuard(reader, false, true);

Expand Down Expand Up @@ -510,7 +526,11 @@ void getEntriesMappingFromArchiveFile(const std::string & archivePath,
void *reader = NULL;

// Create the reader object.
#if MZ_VERSION_BUILD >= 040000
reader = mz_zip_reader_create();
#else
mz_zip_reader_create(&reader);
#endif

MinizipNgHandlerGuard extracterGuard(reader, false, false);

Expand Down Expand Up @@ -630,4 +650,4 @@ void CIOPOciozArchive::buildEntries()
getEntriesMappingFromArchiveFile(m_archiveAbsPath, m_entries);
}

} // namespace OCIO_NAMESPACE
} // namespace OCIO_NAMESPACE
4 changes: 4 additions & 0 deletions src/apps/ocioarchive/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ int main(int argc, const char **argv)
}

std::string path = args[0];
#if MZ_VERSION_BUILD >= 040000
reader = mz_zip_reader_create();
#else
mz_zip_reader_create(&reader);
#endif
struct tm tmu_date;

err = mz_zip_reader_open_file(reader, path.c_str());
Expand Down

0 comments on commit bdc4cd1

Please sign in to comment.