cprover
|
Thin object-oriented wrapper around the MZ Zip library Zip file reader and extractor. More...
#include <mz_zip_archive.h>
Public Member Functions | |
mz_zip_archivet (const std::string &filename) | |
Open a zip archive. More... | |
mz_zip_archivet (const void *data, size_t size) | |
Loads a zip buffer. More... | |
mz_zip_archivet (const mz_zip_archivet &)=delete | |
mz_zip_archivet & | operator= (const mz_zip_archivet &)=delete |
mz_zip_archivet (mz_zip_archivet &&other) | |
Move constructor. Doesn't throw. Leaves other object invalidated. More... | |
mz_zip_archivet & | operator= (mz_zip_archivet &&other) |
Move assignment. More... | |
~mz_zip_archivet () | |
size_t | get_num_files () |
Get number of files in the archive. More... | |
std::string | get_filename (size_t index) |
Get file name of nth file in the archive. More... | |
std::string | extract (size_t index) |
Get contents of nth file in the archive. More... | |
Private Attributes | |
std::unique_ptr< mz_zip_archive_statet > | m_state |
Thin object-oriented wrapper around the MZ Zip library Zip file reader and extractor.
Not thread safe. Move only.
Definition at line 20 of file mz_zip_archive.h.
|
explicit |
Open a zip archive.
filename | Path of the zip archive |
Throws | std::runtime_error if file cannot be opened |
Definition at line 49 of file mz_zip_archive.cpp.
mz_zip_archivet::mz_zip_archivet | ( | const void * | data, |
size_t | size | ||
) |
Loads a zip buffer.
data | pointer to the memory buffer |
size | size of the buffer |
Throws | std::runtime_error if file cannot be opened |
Definition at line 52 of file mz_zip_archive.cpp.
|
delete |
mz_zip_archivet::mz_zip_archivet | ( | mz_zip_archivet && | other | ) |
Move constructor. Doesn't throw. Leaves other object invalidated.
Definition at line 56 of file mz_zip_archive.cpp.
|
default |
std::string mz_zip_archivet::extract | ( | size_t | index | ) |
Get contents of nth file in the archive.
index | id of the file in the archive |
Throws | std::runtime_error if file cannot be extracted |
Definition at line 85 of file mz_zip_archive.cpp.
References m_state, mz_zip_archive_file_stat::m_uncomp_size, MZ_TRUE, mz_zip_reader_extract_to_mem(), and mz_zip_reader_file_stat().
Referenced by jar_filet::get_entry().
std::string mz_zip_archivet::get_filename | ( | size_t | index | ) |
Get file name of nth file in the archive.
index | id of the file in the archive |
Definition at line 74 of file mz_zip_archive.cpp.
References m_state, and mz_zip_reader_get_filename().
Referenced by jar_filet::initialize_file_index().
size_t mz_zip_archivet::get_num_files | ( | ) |
Get number of files in the archive.
Definition at line 69 of file mz_zip_archive.cpp.
References m_state, and mz_zip_reader_get_num_files().
Referenced by jar_filet::initialize_file_index().
|
delete |
mz_zip_archivet & mz_zip_archivet::operator= | ( | mz_zip_archivet && | other | ) |
Move assignment.
Doesn't throw. Replaces this object's state with other object's state. Invalidates other object.
Definition at line 63 of file mz_zip_archive.cpp.
References m_state.
|
private |
Definition at line 55 of file mz_zip_archive.h.
Referenced by extract(), get_filename(), get_num_files(), and operator=().