Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::archive::ArchiveReader Class Reference

Archive reader. More...

#include <ArchiveReader.h>

Public Types

using ExtractCallback = std::function<bool(const std::filesystem::path &base_path, Config::EntryType type, io::InputStream *input, size_t readable)>
 

Public Member Functions

 ArchiveReader (io::InputStream *input)
 
virtual ~ArchiveReader ()
 
int setPassword (const std::string &pwd) const
 
int setOptions (const std::string &opt) const
 
bool extract (const ExtractCallback &callback)
 
int getError () const
 
const char * getErrorString () const
 

Static Public Member Functions

static bool extract (const std::filesystem::path &src_path, const std::filesystem::path &dest_path, const std::string &pwd={})
 
static int openCallback (void *a, ArchiveReader *archive_this)
 
static int64_t readCallback (void *a, ArchiveReader *archive_this, const void **buffer)
 
static int closeCallback (void *a, ArchiveReader *archive_this)
 

Protected Attributes

char buffer [4096] {}
 
void * archive {}
 
io::InputStreaminput {}
 

Detailed Description

Archive reader.

Member Typedef Documentation

◆ ExtractCallback

using sese::archive::ArchiveReader::ExtractCallback = std::function<bool(const std::filesystem::path &base_path, Config::EntryType type, io::InputStream *input, size_t readable)>

Constructor & Destructor Documentation

◆ ArchiveReader()

ArchiveReader::ArchiveReader ( io::InputStream * input)
explicit

Reads the archive from the input stream

Parameters
inputThe input stream

◆ ~ArchiveReader()

ArchiveReader::~ArchiveReader ( )
virtual

References XX.

Member Function Documentation

◆ closeCallback()

int ArchiveReader::closeCallback ( void * a,
ArchiveReader * archive_this )
static

Referenced by close().

◆ extract() [1/2]

bool ArchiveReader::extract ( const ExtractCallback & callback)

Executes the extraction operation

Parameters
callbackThe extraction callback function
Returns
Whether the extraction was successful

References archive, callback(), close(), sese::archive::Config::fromValue(), open(), read(), and XX.

◆ extract() [2/2]

bool ArchiveReader::extract ( const std::filesystem::path & src_path,
const std::filesystem::path & dest_path,
const std::string & pwd = {} )
static

Extracts the archive to the specified location

Parameters
src_pathThe path of the archive
dest_pathThe destination path for extraction
pwdThe password (optional)
Returns
Whether the operation was successful

References a, archive, sese::io::FileStream::B_WRITE_TRUNC, buffer, and write().

◆ getError()

int ArchiveReader::getError ( ) const
nodiscard

Retrieves the current error code

Returns
The error code

References XX.

◆ getErrorString()

const char * ArchiveReader::getErrorString ( ) const
nodiscard

Retrieves the current error message

Returns
The error message

References XX.

◆ openCallback()

int ArchiveReader::openCallback ( void * a,
ArchiveReader * archive_this )
static

Referenced by open().

◆ readCallback()

int64_t ArchiveReader::readCallback ( void * a,
ArchiveReader * archive_this,
const void ** buffer )
static

References buffer, input, and sese::io::InputStream::read().

Referenced by read().

◆ setOptions()

int ArchiveReader::setOptions ( const std::string & opt) const
nodiscard

Sets libarchive options for the current archive

Parameters
optThe options string
Returns
Returns 0 if successful

References XX.

◆ setPassword()

int ArchiveReader::setPassword ( const std::string & pwd) const
nodiscard

Sets the password for the currently read document

Parameters
pwdThe password to be used
Returns
Returns 0 if successful

References XX.

Member Data Documentation

◆ archive

void* sese::archive::ArchiveReader::archive {}
protected

Referenced by extract(), and extract().

◆ buffer

char sese::archive::ArchiveReader::buffer[4096] {}
protected

Referenced by extract(), and readCallback().

◆ input

io::InputStream* sese::archive::ArchiveReader::input {}
protected

Referenced by readCallback().


The documentation for this class was generated from the following files: