LibArchive(3)
| LibArchive(3) | Library Functions Manual | LibArchive(3) |
NAME
LibArchive - The LibArchive class.
SYNOPSIS
#include <LibArchive.h>
Inherited by ArchiveParser, InpxLoader, and RemoveBook.
Public Member Functions
LibArchive (const std::shared_ptr< MLBookProc
> &mlbp)
LibArchive constructor. void listFilesInArchive (const
std::filesystem::path &archive_path, std::vector< std::tuple<
std::string, uint64_t, uint64_t > > &result)
void listFilesInArchiveBuffer (const std::string &buffer,
std::vector< std::tuple< std::string, uint64_t, uint64_t > >
&result)
void listFilesInZip (const std::filesystem::path &archive_path,
std::vector< std::tuple< std::string, uint64_t, uint64_t > >
&result)
void listFilesInZipBuffer (const std::string &buffer,
std::vector< std::tuple< std::string, uint64_t, uint64_t > >
&result)
std::filesystem::path unpackFileToDirectory (const
std::filesystem::path &archive_path, const std::string &filename,
const std::filesystem::path &directory, const size_t
&offset=size_t(0))
std::filesystem::path unpackBufferFileToDirectory (const std::string
&buffer, const std::string &filename, const std::filesystem::path
&directory, const size_t &offset=size_t(0))
std::filesystem::path unpackZipFileToDirectory (const
std::filesystem::path &archive_path, const std::string &filename,
const std::filesystem::path &directory)
std::filesystem::path unpackZipBufferFileToDirectory (const std::string
&buffer, const std::string &filename, const std::filesystem::path
&directory)
std::string unpackFileToBuffer (const std::filesystem::path
&archive_path, const std::string &filename, const size_t
&offset=size_t(0))
std::string unpackBufferFileToBuffer (const std::string &buffer,
const std::string &filename, const size_t &offset=size_t(0))
std::string unpackZipFileToBuffer (const std::filesystem::path
&archive_path, const std::string &filename)
std::string unpackZipBufferFileToBuffer (const std::string &buffer,
const std::string &filename)
void writeToArchive (const std::filesystem::path &source_object,
const std::filesystem::path &archive_path, std::string name_in_archive,
const std::filesystem::perms &perms=std::filesystem::perms::none, const
bool &overwrite_existing=true)
void writeBufferObjectToArchive (const std::string &buffer, const
std::filesystem::path &archive_path, std::string name_in_archive, const
std::filesystem::perms &perms, const bool &overwrite_existing)
Protected Member Functions
std::shared_ptr< archive > initForReading (const
std::shared_ptr< LibArchiveFileData > &fd)
std::shared_ptr< archive > initForWriting (const
std::shared_ptr< LibArchiveFileData > &fd)
void archiveError (const std::shared_ptr< archive > &a, const
std::string &message)
std::filesystem::path unpackToDirectory (std::shared_ptr<
LibArchiveFileData > fd, const std::string &filename, const
std::filesystem::path &directory)
void unpackToBuffer (std::shared_ptr< LibArchiveFileData >
fd, const std::string &filename, std::string &result)
void unpackEntryToDirectory (std::shared_ptr< archive > a,
std::shared_ptr< archive_entry > e, const std::filesystem::path
&file_path)
std::string unpackEntryToBuffer (std::shared_ptr< archive > a,
std::shared_ptr< archive_entry > e)
void writeFile (std::shared_ptr< archive > a, const
std::filesystem::path &path, std::string name_in_archive, const
std::filesystem::perms &perms)
void writeBufferToArchive (std::shared_ptr< archive > a,
std::shared_ptr< archive_entry > e, const std::string &buf)
std::filesystem::perms getPermissionsFromEntry (const
std::shared_ptr< archive_entry > &e)
void setUsernameGroupname (std::shared_ptr< archive_entry > e)
Static Protected Member Functions
static int openCallBack (archive *a, void *client_data)
static la_ssize_t readCallBack (archive *a, void *client_data, const
void **buffer)
static la_int64_t skipCallback (archive *a, void *client_data,
la_int64_t request)
static int closeCallback (archive *a, void *client_data)
static la_int64_t seekCallback (archive *a, void *client_data,
la_int64_t offset, int whence)
static la_ssize_t writeCallback (archive *a, void *client_data, const
void *buffer, size_t length)
Protected Attributes
std::shared_ptr< MLBookProc > mlbp
Detailed Description
The LibArchive class.
This class contains methods to work with archives.
Constructor & Destructor Documentation
LibArchive::LibArchive (const std::shared_ptr< MLBookProc > & mlbp)
LibArchive constructor.
Parameters
Member Function Documentation
void LibArchive::archiveError (const std::shared_ptr< archive > & a, const std::string & message) [protected]
Handles libarchive errors.
This method throws std::exception in all cases.
Parameters
message Message to be prepended to libarchive error message.
int LibArchive::closeCallback (archive * a, void * client_data) [static], [protected]
Close callback function for libarchive.
Parameters
client_data Pointer to client data.
Returns
std::filesystem::perms LibArchive::getPermissionsFromEntry (const std::shared_ptr< archive_entry > & e) [protected]
Returns permissions read from entry.
Parameters
Returns
std::shared_ptr< archive > LibArchive::initForReading (const std::shared_ptr< LibArchiveFileData > & fd) [protected]
Initializes archive for reading.
Note
Parameters
Returns
std::shared_ptr< archive > LibArchive::initForWriting (const std::shared_ptr< LibArchiveFileData > & fd) [protected]
Initializes archive for writing.
Note
Parameters
Returns
void LibArchive::listFilesInArchive (const std::filesystem::path & archive_path, std::vector< std::tuple< std::string, uint64_t, uint64_t > > & result)
Obtains entries from archive.
Note
Parameters
result Vector of obtained entries. First element of tuple - name of object in archive, second - size of unpacked object, third - offset of entry in archive file (this method sets to 0 in all cases).
void LibArchive::listFilesInArchiveBuffer (const std::string & buffer, std::vector< std::tuple< std::string, uint64_t, uint64_t > > & result)
Same as listFilesInArchive(), but obtains entiries from archive placed in buffer.
Note
Parameters
result Vector of obtained entries. First element of tuple - name of object in archive, second - size of unpacked object, third - offset of entry in archive file (this method sets to 0 in all cases).
void LibArchive::listFilesInZip (const std::filesystem::path & archive_path, std::vector< std::tuple< std::string, uint64_t, uint64_t > > & result)
Same as listFilesInArchive(), but designed specially for zip archives. This method can be used to other archives also, but it uses listFilesInArchive() in those cases.
Note
Parameters
result Vector of obtained entries. First element of tuple - name of object in archive, second - size of unpacked object, third - offset of entry in archive file (will be set to 0 in case of non zip archives).
void LibArchive::listFilesInZipBuffer (const std::string & buffer, std::vector< std::tuple< std::string, uint64_t, uint64_t > > & result)
Same as listFilesInZip(), but but obtains entiries from archive placed in buffer.
Note
Parameters
result Vector of obtained entries. First element of tuple - name of object in archive, second - size of unpacked object, third - offset of entry in archive file (will be set to 0 in case of non zip archives).
int LibArchive::openCallBack (archive * a, void * client_data) [static], [protected]
Open callback function for libarchive.
Parameters
client_data Pointer to client data.
Returns
la_ssize_t LibArchive::readCallBack (archive * a, void * client_data, const void ** buffer) [static], [protected]
Read callback function for libarchive.
Parameters
client_data Pointer to client data.
buffer Pointer to buffer.
Returns
la_int64_t LibArchive::seekCallback (archive * a, void * client_data, la_int64_t offset, int whence) [static], [protected]
Seek callback function for libarchive.
Parameters
client_data Pointer to client data.
offset Requested offset.
whence The possibilities for the third argument to fseek.
Returns
void LibArchive::setUsernameGroupname (std::shared_ptr< archive_entry > e) [protected]
Sets user id, group id (only Linux), user name and group name to entry.
Parameters
la_int64_t LibArchive::skipCallback (archive * a, void * client_data, la_int64_t request) [static], [protected]
Skip callback function for libarchive.
Parameters
client_data Pointer to client data.
request Number of bytes to skip.
Returns
std::string LibArchive::unpackBufferFileToBuffer (const std::string & buffer, const std::string & filename, const size_t & offset = size_t(0))
Same as unpackFileToBuffer(), but uses buffered archive as source.
Note
Parameters
filename Name of file in archive.
offset Offset of file entry in archive (should be set only in case of zip archives).
Returns
std::filesystem::path LibArchive::unpackBufferFileToDirectory (const std::string & buffer, const std::string & filename, const std::filesystem::path & directory, const size_t & offset = size_t(0))
Same as unpackFileToDirectory(), but uses buffered archive.
Note
Parameters
filename Name of file in archive.
directory Path to directory file should be unpacked to.
offset Offset of file entry in archive (should be set only in case of zip archives).
Returns
std::string LibArchive::unpackEntryToBuffer (std::shared_ptr< archive > a, std::shared_ptr< archive_entry > e) [protected]
Unpacks single entry to buffer.
Parameters
e Smart pointer to archive_entry object (see libarchive documentation for details).
Returns
void LibArchive::unpackEntryToDirectory (std::shared_ptr< archive > a, std::shared_ptr< archive_entry > e, const std::filesystem::path & file_path) [protected]
Unpacks single entry to directory.
Parameters
e Smart pointer to archive_entry object (see libarchive documentation for details).
file_path Path entry should be unpacked to.
std::string LibArchive::unpackFileToBuffer (const std::filesystem::path & archive_path, const std::string & filename, const size_t & offset = size_t(0))
Unpacks file to buffer.
Note
Parameters
filename Name of file in archive.
offset Offset of file entry in archive (should be set only in case of zip archives).
Returns
std::filesystem::path LibArchive::unpackFileToDirectory (const std::filesystem::path & archive_path, const std::string & filename, const std::filesystem::path & directory, const size_t & offset = size_t(0))
Unpacks single file from archive to given directory.
Note
Parameters
filename Name of file in archive.
directory Path to directory file should be unpacked to.
offset Offset of file entry in archive (should be set only in case of zip archives).
Returns
void LibArchive::unpackToBuffer (std::shared_ptr< LibArchiveFileData > fd, const std::string & filename, std::string & result) [protected]
Unpacks file to buffer.
Note
Parameters
filename File to be unpacked.
result Buffer file to be unpacked to.
std::filesystem::path LibArchive::unpackToDirectory (std::shared_ptr< LibArchiveFileData > fd, const std::string & filename, const std::filesystem::path & directory) [protected]
Unpacks file to directory.
Note
Parameters
filename File to be unpacked.
directory Directory file to be unpacked to.
Returns
std::string LibArchive::unpackZipBufferFileToBuffer (const std::string & buffer, const std::string & filename)
Same as unpackZipFileToBuffer(), but uses buffered archive instead.
Note
Parameters
filename Name of file in archive.
Returns
std::filesystem::path LibArchive::unpackZipBufferFileToDirectory (const std::string & buffer, const std::string & filename, const std::filesystem::path & directory)
Same as unpackZipFileToDirectory(), but uses buffered archive as source.
Note
Parameters
filename Name of file in archive.
directory Path to directory file should be unpacked to.
Returns
std::string LibArchive::unpackZipFileToBuffer (const std::filesystem::path & archive_path, const std::string & filename)
Same as unpackFileToBuffer(), but designed for zip archives specially. This method can be used for other types of archives, but it uses unpackFileToBuffer() in those cases.
Note
Parameters
filename Name of file in archive.
Returns
std::filesystem::path LibArchive::unpackZipFileToDirectory (const std::filesystem::path & archive_path, const std::string & filename, const std::filesystem::path & directory)
Same as unpackFileToDirectory(), but designed for zip archives specially. This method can be used for other types of archives, but it uses unpackFileToDirectory() in those cases.
Note
Parameters
filename Name of file in archive.
directory Path to directory file should be unpacked to.
Returns
void LibArchive::writeBufferObjectToArchive (const std::string & buffer, const std::filesystem::path & archive_path, std::string name_in_archive, const std::filesystem::perms & perms, const bool & overwrite_existing)
Same as writeToArchive(), but uses buffer as source.
Note
Parameters
archive_path Path to archive.
name_in_archive Name of file in archive.
perms File permissions.
overwrite_existing If true archive will be overwritten. If false archive will be repacked and file will be appended to new archive.
void LibArchive::writeBufferToArchive (std::shared_ptr< archive > a, std::shared_ptr< archive_entry > e, const std::string & buf) [protected]
Writes buffer to archive.
Parameters
e Smart pointer to archive_entry object (see libarchive documentation for details).
buf Buffer to be packed.
la_ssize_t LibArchive::writeCallback (archive * a, void * client_data, const void * buffer, size_t length) [static], [protected]
Write callback function for libarchive.
Parameters
client_data Pointer to client data.
buffer Buffer to be written.
length Size of given buffer.
Returns
void LibArchive::writeFile (std::shared_ptr< archive > a, const std::filesystem::path & path, std::string name_in_archive, const std::filesystem::perms & perms) [protected]
Writes file to archive.
Parameters
path Path to file to be packed.
name_in_archive Name of file in archive.
perms File permissions.
void LibArchive::writeToArchive (const std::filesystem::path & source_object, const std::filesystem::path & archive_path, std::string name_in_archive, const std::filesystem::perms & perms = std::filesystem::perms::none, const bool & overwrite_existing = true)
Writes file to archive.
Note
Parameters
archive_path Path to archive.
name_in_archive Name of file in archive.
perms File permissions. In case of std::filesystem::perms::none, source_object permissions will be used.
overwrite_existing If true archive will be overwritten. If false archive will be repacked and file will be appended to new archive.
Member Data Documentation
std::shared_ptr<MLBookProc> LibArchive::mlbp [protected]
Smart pointer to MLBookProc object.
Warning
Author
Generated automatically by Doxygen for MLBookProc from the source code.
| Version 2.1 | MLBookProc |
