![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/Zip.h>
Class representing a zip archive. A ZipArchive instance can create a zip archive, add/extract files/memory buffers to/from it. More...
Class representing a zip archive. A ZipArchive instance can create a zip archive, add/extract files/memory buffers to/from it.
Public Member Functions | |
| ZipArchive (const Filesystem::Path &archivePath, ExistingArchivePolicy archivePolicy=ExistingArchivePolicy::Append) | |
| Constructor with the path of the archive, should be a valid file path. | |
| ZipArchive (ByteBufferView buffer) | |
| Constructor with a buffer. | |
| Utils::Expected< void, Error > | add (const Filesystem::Path &inputPath, Algorithm algorithm=Algorithm::ZLib, Level level=Level::Default) |
| Adds a file or folder at inputPath to the zip archive. | |
| Utils::Expected< void, Error > | add (const ByteBufferView &buffer, const Filesystem::Path &entryName, Algorithm algorithm=Algorithm::ZLib, Level level=Level::Default) |
Adds the content of the buffer to the zip archive using the given entryName. | |
| Utils::Expected< void, Error > | extractAll (const Filesystem::Directory &outputDir) const |
| Extracts the current archive into the given outputDir directory. If the directory does not exists, it is created. | |
| Utils::Expected< ByteBuffer, Error > | extractSingle (const Filesystem::Path &entryPath) const |
Extracts a single entry inside the archive with path entryPath into a memory buffer. | |
| Utils::Expected< void, Error > | extractSingle (const Filesystem::Path &entryPath, const Filesystem::Directory &outputDir) const |
Extracts a single entry inside the archive with path entryPath into the directory outputDir. | |
| Utils::Expected< EntryInfo, Error > | entryInfo (const Filesystem::Path &entryPath) const |
Returns information about the entry with path entryPath. | |
| Utils::Expected< std::vector< EntryInfo >, Error > | listEntries (bool listDirectories=false) const |
| Lists information about the entries of the archive. | |
|
explicit |
Constructor with the path of the archive, should be a valid file path.
| existingArchivePolicy | indicates if the (existing) archive should be overwritten or files appended to it. |
| std::invalid_argument | if the path is empty or not a valid file path. |
|
explicit |
Constructor with a buffer.
| Utils::Expected< void, Error > add | ( | const Filesystem::Path & | inputPath, |
| Algorithm | algorithm = Algorithm::ZLib, | ||
| Level | level = Level::Default ) |
Adds a file or folder at inputPath to the zip archive.
The file is compressed using the given compression algorithm and the given compression level. Note: If the file is already present in the archive, an error is returned.
| Utils::Expected< void, Error > add | ( | const ByteBufferView & | buffer, |
| const Filesystem::Path & | entryName, | ||
| Algorithm | algorithm = Algorithm::ZLib, | ||
| Level | level = Level::Default ) |
Adds the content of the buffer to the zip archive using the given entryName.
The content of the buffer is compressed using the given compression algorithm. Note: If an entry with name "entryName" is already present in the archive, an error is returned.
| Utils::Expected< std::vector< EntryInfo >, Error > listEntries | ( | bool | listDirectories = false | ) | const |
Lists information about the entries of the archive.
Note: If listDirectories is set to true, directories are listed, otherwise only files.