Orcus
Public Member Functions | List of all members
orcus::zip_archive Class Reference

Public Member Functions

 zip_archive (zip_archive_stream *stream)
 
void load ()
 
void dump_file_entry (size_t index) const
 
void dump_file_entry (const char *entry_name) const
 
pstring get_file_entry_name (size_t index) const
 
size_t get_file_entry_count () const
 
bool read_file_entry (const pstring &entry_name, std::vector< unsigned char > &buf) const
 

Member Function Documentation

void orcus::zip_archive::dump_file_entry ( size_t  index) const

Dump the content of a specified file entry to stdout.

Parameters
indexfile entry index
void orcus::zip_archive::dump_file_entry ( const char *  entry_name) const

Dump the content of a specified file entry to stdout.

Parameters
entry_namefile entry name.
size_t orcus::zip_archive::get_file_entry_count ( ) const

Return the number of file entries stored in this zip archive. Note that a file entry may be a directory, so the number of files stored in the zip archive may not equal the number of file entries.

Returns
number of file entries.
pstring orcus::zip_archive::get_file_entry_name ( size_t  index) const

Get file entry name from its index.

Parameters
indexfile entry index
Returns
file entry name
void orcus::zip_archive::load ( )

Loading involves the parsing of the central directory of a zip archive (located toward the end of the stream) and building of file entry data which are stored in the central directory.

bool orcus::zip_archive::read_file_entry ( const pstring entry_name,
std::vector< unsigned char > &  buf 
) const

Retrieve data stream of specified file entry into buffer. The retrieved data stream gets uncompressed if the original stream is compressed. The method will overwrite the content of passed buffer if there is any pre-existing data in it.

Parameters
entry_namefile entry name
bufbuffer to put the retrieved data stream into.
Returns
true if successful, false otherwise.