#include <icy/archo/zipfile.h>ZIP archive reader and writer.
std::vector< FileInfo > infounzFile fp| Return | Name | Description |
|---|---|---|
ZipFile | Constructs an unopened ZipFile. Call open() before use. | |
ZipFile explicit | Constructs a ZipFile and immediately opens the archive at file. | |
~ZipFile | Closes the archive if still open. | |
ZipFile | Deleted constructor. | |
ZipFile | Deleted constructor. | |
void | open | Opens the archive at file, closing any previously opened archive. Populates the info vector with metadata for every entry. |
bool | opened const | Returns true if the archive is currently open. |
void | close | Closes the archive and releases the underlying file handle. |
void | extract | Extracts the archive contents to the given directory path. |
bool | extractCurrentFile | Extracts the current file entry to path. Validates each entry against path-traversal attacks before writing. |
bool | goToFirstFile | Moves the internal cursor to the first file entry in the archive. |
bool | goToNextFile | Advances the internal cursor to the next file entry. |
void | openCurrentFile | Opens the current file entry for reading. |
void | closeCurrentFile | Closes the current file entry. |
std::string | currentFileName | Returns the name (relative path) of the current file entry. |
ZipFile()Constructs an unopened ZipFile. Call open() before use.
explicit
explicit ZipFile(const std::filesystem::path & file)Constructs a ZipFile and immediately opens the archive at file.
file Path to the ZIP archive to open.~ZipFile()Closes the archive if still open.
ZipFile(const ZipFile &) = deleteDeleted constructor.
ZipFile(ZipFile &&) = deleteDeleted constructor.
void open(const std::filesystem::path & file)Opens the archive at file, closing any previously opened archive. Populates the info vector with metadata for every entry.
file Path to the ZIP archive.std::runtime_error if the file cannot be opened.const
bool opened() constReturns true if the archive is currently open.
void close()Closes the archive and releases the underlying file handle.
void extract(const std::filesystem::path & path)Extracts the archive contents to the given directory path.
path Destination directory; created automatically if necessary.std::runtime_error if the archive is not open or a read error occurs.bool extractCurrentFile(const std::filesystem::path & path, bool whiny)Extracts the current file entry to path. Validates each entry against path-traversal attacks before writing.
path Destination base directory.
whiny If true, re-throws on error; otherwise returns false.
true on success, false if whiny is false and an error occurred.
bool goToFirstFile()Moves the internal cursor to the first file entry in the archive.
true on success, false if the archive is empty or an error occurred.
bool goToNextFile()Advances the internal cursor to the next file entry.
true if another entry exists, false at end-of-list.
void openCurrentFile()Opens the current file entry for reading.
std::runtime_error on failure.void closeCurrentFile()Closes the current file entry.
std::runtime_error on failure.std::string currentFileName()Returns the name (relative path) of the current file entry.
Entry name as reported by the ZIP directory.