archo
March 26, 2026 ยท View on GitHub
{#archivemodule}
archo
Archive and ZIP file handling.
Namespaces
| Name | Description |
|---|---|
archo | ZIP archive handling utilities and related helpers. |
Macros
| Name | Description |
|---|---|
Archo_API | Shared library exports. |
{#archo_api}
Archo_API
Archo_API()
Shared library exports.
{#archo}
archo
ZIP archive handling utilities and related helpers.
Classes
| Name | Description |
|---|---|
ZipFile | ZIP archive reader and writer. |
{#zipfile}
ZipFile
#include <icy/archo/zipfile.h>
ZIP archive reader and writer.
Public Attributes
| Return | Name | Description |
|---|---|---|
std::vector< FileInfo > | info | |
unzFile | fp |
{#info}
info
std::vector< FileInfo > info
{#fp}
fp
unzFile fp
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-1}
ZipFile
ZipFile()
Constructs an unopened ZipFile. Call open() before use.
{#zipfile-2}
ZipFile
explicit
explicit ZipFile(const std::filesystem::path & file)
Constructs a ZipFile and immediately opens the archive at file.
Parameters
filePath to the ZIP archive to open.
{#zipfile-3}
~ZipFile
~ZipFile()
Closes the archive if still open.
{#zipfile-4}
ZipFile
ZipFile(const ZipFile &) = delete
Deleted constructor.
{#zipfile-5}
ZipFile
ZipFile(ZipFile &&) = delete
Deleted constructor.
{#open-5}
open
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.
Parameters
filePath to the ZIP archive.
Exceptions
std::runtime_errorif the file cannot be opened.
{#opened}
opened
const
bool opened() const
Returns true if the archive is currently open.
{#close-23}
close
void close()
Closes the archive and releases the underlying file handle.
{#extract}
extract
void extract(const std::filesystem::path & path)
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}
extractCurrentFile
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.
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}
goToFirstFile
bool goToFirstFile()
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}
goToNextFile
bool goToNextFile()
Advances the internal cursor to the next file entry.
Returns
true if another entry exists, false at end-of-list.
{#opencurrentfile}
openCurrentFile
void openCurrentFile()
Opens the current file entry for reading.
Exceptions
std::runtime_erroron failure.
{#closecurrentfile}
closeCurrentFile
void closeCurrentFile()
Closes the current file entry.
Exceptions
std::runtime_erroron failure.
{#currentfilename}
currentFileName
std::string currentFileName()
Returns the name (relative path) of the current file entry.
Returns
Entry name as reported by the ZIP directory.
{#fileinfo}
FileInfo
#include <icy/archo/zipfile.h>
Metadata for a file entry within a ZIP archive.
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | path | Relative path of the entry within the archive. |
size_t | compressedSize | Compressed size in bytes. |
size_t | uncompressedSize | Uncompressed size in bytes. |
{#path-2}
path
std::string path
Relative path of the entry within the archive.
{#compressedsize}
compressedSize
size_t compressedSize
Compressed size in bytes.
{#uncompressedsize}
uncompressedSize
size_t uncompressedSize
Uncompressed size in bytes.