ImFusion SDK 4.3
ZipArchive Class Reference

#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...

Detailed Description

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, Erroradd (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, Erroradd (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, ErrorextractAll (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, ErrorextractSingle (const Filesystem::Path &entryPath) const
 Extracts a single entry inside the archive with path entryPath into a memory buffer.
 
Utils::Expected< void, ErrorextractSingle (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, ErrorentryInfo (const Filesystem::Path &entryPath) const
 Returns information about the entry with path entryPath.
 
Utils::Expected< std::vector< EntryInfo >, ErrorlistEntries (bool listDirectories=false) const
 Lists information about the entries of the archive.
 

Constructor & Destructor Documentation

◆ ZipArchive() [1/2]

ZipArchive ( const Filesystem::Path & archivePath,
ExistingArchivePolicy archivePolicy = ExistingArchivePolicy::Append )
explicit

Constructor with the path of the archive, should be a valid file path.

Parameters
existingArchivePolicyindicates if the (existing) archive should be overwritten or files appended to it.
Exceptions
std::invalid_argumentif the path is empty or not a valid file path.

◆ ZipArchive() [2/2]

ZipArchive ( ByteBufferView buffer)
explicit

Constructor with a buffer.

Note
This is a read-only archive. Every attempt to write to it will fail.

Member Function Documentation

◆ add() [1/2]

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.

◆ add() [2/2]

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.

◆ listEntries()

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.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close