Solutions
79. Finding files in a ZIP archive
There are a variety of libraries that provide support for working with ZIP archives. Among the ones available for free, the most used ones include ZipLib, Info-Zip, MiniZip, and LZMA SDK from 7z. And then, there are also commercial implementations. For the problems regarding ZIP archives in this book, I have chosen ZipLib
. This is a lightweight, open source cross-platform C++11 library built around standard library streams, with no additional dependencies. The library, along with its documentation, is available at https://bitbucket.org/wbenny/ziplib.
To implement the required functionality, you have to:
- Open the ZIP archive using
ZipFile::Open()
- Enumerate all the entries in the archive using
ZipArchive::GetEntry()
andZipArchive::GetEntryCount()
- For all entries that represent files, check that the name matches the provided regular expression using
ZipArchiveEntry::GetName()
- For all entries that match the regular expression, add the full name to the...