35 int main(
int argc,
char *argv[])
39 std::cerr <<
"error: usage: zipios_example <path to test.zip> <filename to extract and print>" << std::endl;
40 std::cerr <<
" from the source directory, try as:" << std::endl;
41 std::cerr <<
" zipios_example tests/test.zip test2.txt" << std::endl;
47 std::cout <<
"Instantiating a ZipFile" << std::endl;
50 std::cout <<
"list length: " << zf.
size() << std::endl;
53 for(
auto it = entries.begin(); it != entries.end(); ++it)
55 std::cout <<
" " << *(*it) << std::endl;
64 std::cout <<
"Contents of entry, " << ent->getName() <<
":" << std::endl;
66 std::cout << is->rdbuf();
70 std::cerr <<
"error: found an entry for " << ent->getName() <<
" in test.zip, but could not read it with getInputStream()" << std::endl;
75 std::cerr <<
"error: could not read " << ent->getName() <<
" from test.zip" << std::endl;
78 std::cout <<
"end of main()" << std::endl;
80 catch(std::exception
const& e)
82 std::cerr <<
"Exception caught in main() :" << std::endl;
83 std::cerr << e.what() << std::endl;
The ZipFile class represents a collection of files.
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
int main(int argc, char *argv[])
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
virtual size_t size() const
Returns the number of entries in the FileCollection.
Define the zipios::ZipFile class.
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH) override
Retrieve a pointer to a file in the Zip archive.
std::shared_ptr< FileEntry > pointer_t
std::vector< pointer_t > vector_t