This source code is a small program that demonstrates the central elements of Zipios.
int main(
int argc,
char *argv[])
{
if(argc != 3)
{
std::cerr << "error: usage: zipios_example <path to test.zip> <filename to extract and print>" << std::endl;
std::cerr << " from the source directory, try as:" << std::endl;
std::cerr << " zipios_example tests/test.zip test2.txt" << std::endl;
return 1;
}
try
{
std::cout << "Instantiating a ZipFile" << std::endl;
std::cout << "list length: " << zf.size() << std::endl;
for(auto it = entries.begin(); it != entries.end(); ++it)
{
std::cout << " " << *(*it) << std::endl;
}
if(ent)
{
if(is)
{
std::cout << "Contents of entry, " << ent->getName() << ":" << std::endl;
std::cout << is->rdbuf() << "\n";
}
else
{
std::cerr << "error: found an entry for " << ent->getName() << " in test.zip, but could not read it with getInputStream()" << std::endl;
}
}
else
{
std::cerr << "error: could not read " << argv[2] << " from test.zip" << std::endl;
}
std::cout << "end of main()" << std::endl;
}
catch(std::exception const& e)
{
std::cerr << "Exception caught in main() :" << std::endl;
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
int main(int argc, char *argv[])
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
std::shared_ptr< FileEntry > pointer_t
std::vector< pointer_t > vector_t
The ZipFile class represents a collection of files.
Define the zipios::ZipFile class.