Go to the documentation of this file.
13 #define _LARGEFILE64_SOURCE 1
25 throw std::runtime_error(
"MZT: Could not load a file: "+filename);
32 throw std::runtime_error(
"MZT: Could not load data from memory");
45 static_assert(
sizeof(
mz_uint)<=
sizeof(
size_t),
46 "size_t cannot store mz_zip file ids, choose a larger type");
56 m_state(std::move(other.m_state)) { }
64 m_state=std::move(other.m_state);
75 const auto id =
static_cast<mz_uint>(index);
81 std::string buffer(name_size,
'\0');
84 buffer.resize(name_size - 1);
90 const auto id=
static_cast<mz_uint>(index);
99 m_state.get(),
id, &buffer[0], buffer.size(), 0);
103 throw std::runtime_error(
"Could not extract the file");
108 const std::string &path)
110 const auto id =
static_cast<mz_uint>(index);
115 throw std::runtime_error(
"Could not extract the file");
mz_uint mz_zip_reader_get_num_files(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_bool mz_zip_reader_end(mz_zip_archive *pZip)
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
mz_zip_archivet(const std::string &filename)
Open a zip archive.
mz_zip_archive_statet(const void *data, size_t size)
std::string extract(size_t index)
Get contents of nth file in the archive.
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
mz_zip_archivet & operator=(const mz_zip_archivet &)=delete
mz_zip_archive_statet(const std::string &filename)
size_t get_num_files()
Get number of files in the archive.
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_zip_archive_statet & operator=(const mz_zip_archive_statet &)=delete
std::string get_filename(size_t index)
Get file name of nth file in the archive.
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
Thin object-oriented wrapper around the MZ Zip library Zip file reader and extractor.
void extract_to_file(size_t index, const std::string &path)
Write contents of nth file in the archive to a file.
std::unique_ptr< mz_zip_archive_statet > m_state