ZipFile
ZipFile
#include <icy/archo/zipfile.h>struct ZipFileDefined in src/archo/include/icy/archo/zipfile.h:35
ZIP archive reader and writer.
List of all members
| Name | Kind | Owner |
|---|---|---|
info | variable | Declared here |
fp | variable | Declared here |
ZipFile | function | Declared here |
ZipFile | function | Declared here |
~ZipFile | function | Declared here |
ZipFile | function | Declared here |
operator= | function | Declared here |
ZipFile | function | Declared here |
operator= | function | Declared here |
open | function | Declared here |
opened | function | Declared here |
close | function | Declared here |
extract | function | Declared here |
extractCurrentFile | function | Declared here |
goToFirstFile | function | Declared here |
goToNextFile | function | Declared here |
openCurrentFile | function | Declared here |
closeCurrentFile | function | Declared here |
currentFileName | function | Declared here |
Public Attributes
info
std::vector< FileInfo > infoDefined in src/archo/include/icy/archo/zipfile.h:104
fp
unzFile fpDefined in src/archo/include/icy/archo/zipfile.h:105
Public Methods
| 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
ZipFile()Defined in src/archo/include/icy/archo/zipfile.h:38
Constructs an unopened ZipFile. Call open() before use.
ZipFile
explicit
explicit ZipFile(const std::filesystem::path & file)Defined in src/archo/include/icy/archo/zipfile.h:42
Constructs a ZipFile and immediately opens the archive at file.
Parameters
filePath to the ZIP archive to open.
~ZipFile
~ZipFile()Defined in src/archo/include/icy/archo/zipfile.h:45
Closes the archive if still open.
ZipFile
ZipFile(const ZipFile &) = deleteDefined in src/archo/include/icy/archo/zipfile.h:47
Deleted constructor.
ZipFile
ZipFile(ZipFile &&) = deleteDefined in src/archo/include/icy/archo/zipfile.h:49
Deleted constructor.
open
void open(const std::filesystem::path & file)Defined in src/archo/include/icy/archo/zipfile.h:56
Opens the archive at file, closing any previously opened archive. Populates the info vector with metadata for every entry.
Parameters
filePath to the ZIP archive.
Exceptions
std::runtime_errorif the file cannot be opened.
opened
const
bool opened() constDefined in src/archo/include/icy/archo/zipfile.h:59
Returns true if the archive is currently open.
close
void close()Defined in src/archo/include/icy/archo/zipfile.h:62
Closes the archive and releases the underlying file handle.
extract
void extract(const std::filesystem::path & path)Defined in src/archo/include/icy/archo/zipfile.h:67
Extracts the archive contents to the given directory path.
Parameters
pathDestination directory; created automatically if necessary.
Exceptions
std::runtime_errorif the archive is not open or a read error occurs.
extractCurrentFile
bool extractCurrentFile(const std::filesystem::path & path, bool whiny = true)Defined in src/archo/include/icy/archo/zipfile.h:74
Extracts the current file entry to path. Validates each entry against path-traversal attacks before writing.
Parameters
pathDestination base directory.whinyIf true, re-throws on error; otherwise returns false.
Returns
true on success, false if whiny is false and an error occurred.
goToFirstFile
bool goToFirstFile()Defined in src/archo/include/icy/archo/zipfile.h:78
Moves the internal cursor to the first file entry in the archive.
Returns
true on success, false if the archive is empty or an error occurred.
goToNextFile
bool goToNextFile()Defined in src/archo/include/icy/archo/zipfile.h:82
Advances the internal cursor to the next file entry.
Returns
true if another entry exists, false at end-of-list.
openCurrentFile
void openCurrentFile()Defined in src/archo/include/icy/archo/zipfile.h:86
Opens the current file entry for reading.
Exceptions
std::runtime_erroron failure.
closeCurrentFile
void closeCurrentFile()Defined in src/archo/include/icy/archo/zipfile.h:90
Closes the current file entry.
Exceptions
std::runtime_erroron failure.
currentFileName
std::string currentFileName()Defined in src/archo/include/icy/archo/zipfile.h:94
Returns the name (relative path) of the current file entry.
Returns
Entry name as reported by the ZIP directory.
