12 #define _LARGEFILE64_SOURCE 1
24 throw std::runtime_error(
"MZT: Could not load a file: "+filename);
31 throw std::runtime_error(
"MZT: Could not load data from memory");
44 static_assert(
sizeof(
mz_uint)<=
sizeof(
size_t),
45 "size_t cannot store mz_zip file ids, choose a larger type");
55 m_state(std::move(other.m_state)) { }
63 m_state=std::move(other.m_state);
74 const auto id =
static_cast<mz_uint>(index);
80 std::string buffer(name_size,
'\0');
83 buffer.resize(name_size - 1);
89 const auto id=
static_cast<mz_uint>(index);
98 m_state.get(),
id, &buffer[0], buffer.size(), 0);
102 throw std::runtime_error(
"Could not extract the file");
107 const std::string &path)
109 const auto id =
static_cast<mz_uint>(index);
114 throw std::runtime_error(
"Could not extract the file");
mz_zip_archive_statet(mz_zip_archive_statet &&)=delete
mz_zip_archive_statet(const std::string &filename)
mz_zip_archive_statet(const void *data, size_t size)
mz_zip_archive_statet(const mz_zip_archive_statet &)=delete
mz_zip_archive_statet & operator=(const mz_zip_archive_statet &)=delete
mz_zip_archive_statet & operator=(mz_zip_archive_statet &&)=delete
Thin object-oriented wrapper around the MZ Zip library Zip file reader and extractor.
size_t get_num_files()
Get number of files in the archive.
std::string extract(size_t index)
Get contents of nth file in the archive.
void extract_to_file(size_t index, const std::string &path)
Write contents of nth file in the archive to a file.
std::string get_filename(size_t index)
Get file name of nth file in the archive.
mz_zip_archivet & operator=(const mz_zip_archivet &)=delete
std::unique_ptr< mz_zip_archive_statet > m_state
mz_zip_archivet(const std::string &filename)
Open a zip archive.
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
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)
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags)
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_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, 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)