14 #define _LARGEFILE64_SOURCE 1 26 throw std::runtime_error(
"MZT: Could not load a file: "+filename);
33 throw std::runtime_error(
"MZT: Could not load data from memory");
46 static_assert(
sizeof(
mz_uint)<=
sizeof(
size_t),
47 "size_t cannot store mz_zip file ids, choose a larger type");
57 m_state(
std::move(other.m_state)) { }
65 m_state=std::move(other.m_state);
76 const auto id=
static_cast<mz_uint>(index);
77 std::vector<char> buffer;
81 const auto null_char_it=std::find(buffer.cbegin(), buffer.cend(),
'\0');
82 return { buffer.cbegin(), null_char_it };
87 const auto id=
static_cast<mz_uint>(index);
94 m_state.get(), id, buffer.data(), buffer.size(), 0);
96 return { buffer.cbegin(), buffer.cend() };
98 throw std::runtime_error(
"Could not extract the file");
mz_zip_archivet(const std::string &filename)
Open a zip archive.
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
std::string extract(size_t index)
Get contents of nth file in the archive.
Thin object-oriented wrapper around the MZ Zip library Zip file reader and extractor.
std::unique_ptr< mz_zip_archive_statet > m_state
mz_zip_archive_statet & operator=(const mz_zip_archive_statet &)=delete
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags)
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags)
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
mz_zip_archive_statet(const std::string &filename)
std::string get_filename(size_t index)
Get file name of nth file in the archive.
mz_zip_archive_statet(const void *data, size_t size)
size_t get_num_files()
Get number of files in the archive.
mz_zip_archivet & operator=(const mz_zip_archivet &)=delete