bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
BitNestedArchiveReader Class Referencefinal

The BitNestedArchiveReader class allows reading and extracting nested archives (e.g., the tarball inside a .tar.gz archive). More...

#include <bit7z/bitnestedarchivereader.hpp>

Inheritance diagram for BitNestedArchiveReader:
Collaboration diagram for BitNestedArchiveReader:

Public Member Functions

 BitNestedArchiveReader (const Bit7zLibrary &lib, const BitInputArchive &parentArchive, const BitInFormat &format, const tstring &password={})
 Constructs a BitNestedArchiveReader object of the first item in the parent archive.
 BitNestedArchiveReader (const Bit7zLibrary &lib, const BitInputArchive &parentArchive, std::uint32_t index, const BitInFormat &format, const tstring &password={})
 Constructs a BitNestedArchiveReader object.
auto archiveProperty (BitProperty property) const -> BitPropVariant
 Gets the specified archive property.
void clearPassword () noexcept
 Clear the current password used by the handler.
auto detectedFormat () const noexcept -> const BitInFormat &
auto extractionFormat () const noexcept -> const BitInFormat &
void extractTo (const tstring &outDir) const
 Extracts the archive to the chosen directory.
void extractTo (std::map< tstring, buffer_t > &outMap) const
 Extracts the content of the archive to a map of memory buffers, where the keys are the paths of the files (inside the archive), and the values are their decompressed contents.
auto fileCallback () const -> const FileCallback &
auto format () const noexcept -> const BitInFormat &override
auto isPasswordDefined () const noexcept -> bool
auto itemProperty (std::uint32_t index, BitProperty property) const -> BitPropVariant
 Gets the specified property of an item in the archive.
auto items () const -> std::vector< BitArchiveItemInfo >
auto itemsCount () const -> std::uint32_t
auto library () const noexcept -> const Bit7zLibrary &
auto maxMemoryUsage () const noexcept -> std::uint64_t
auto openCount () const -> std::size_t
auto overwriteMode () const noexcept -> OverwriteMode
auto password () const -> const tstring &
auto passwordCallback () const -> const PasswordCallback &
auto progressCallback () const -> const ProgressCallback &
auto ratioCallback () const -> const RatioCallback &
auto retainDirectories () const noexcept -> bool
void setFileCallback (const FileCallback &callback)
 Sets the function to be called when the current file being processed changes.
void setMaxMemoryUsage (std::uint64_t value) noexcept
 Sets the max memory usage limit to be used while extracting the parent archive.
void setOverwriteMode (OverwriteMode mode)
 Sets how the handler should behave when it tries to output to an existing file or buffer.
virtual void setPassword (const tstring &password)
 Sets up a password to be used by the archive handler.
void setPasswordCallback (const PasswordCallback &callback)
 Sets the function to be called when a password is needed to complete the ongoing operation.
void setProgressCallback (const ProgressCallback &callback)
 Sets the function to be called when the processed size of the ongoing operation is updated.
void setRatioCallback (const RatioCallback &callback)
 Sets the function to be called when the input processed size and current output size of the ongoing operation are known.
void setRetainDirectories (bool retain) noexcept
 Sets whether the operations' output will preserve the input's directory structure or not.
void setTotalCallback (const TotalCallback &callback)
 Sets the function to be called when the total size of an operation is available.
void test () const
 Tests the archive without extracting its content.
auto totalCallback () const -> const TotalCallback &

Detailed Description

The BitNestedArchiveReader class allows reading and extracting nested archives (e.g., the tarball inside a .tar.gz archive).

Constructor & Destructor Documentation

◆ BitNestedArchiveReader() [1/2]

BitNestedArchiveReader ( const Bit7zLibrary & lib,
const BitInputArchive & parentArchive,
std::uint32_t index,
const BitInFormat & format,
const tstring & password = {} )

Constructs a BitNestedArchiveReader object.

Note
The constructor doesn't open the archive, it will be opened only when needed.
Parameters
libthe 7z library used.
parentArchivethe parent archive containing the nested archive.
indexthe index of the nested archive within the parent archive.
formatthe format of the nested archive.
password(optional) the password needed for opening the nested archive.
Exceptions
BitExceptionif the format is BitFormat::Auto (automatic format detection of nested archives is not supported).

◆ BitNestedArchiveReader() [2/2]

BitNestedArchiveReader ( const Bit7zLibrary & lib,
const BitInputArchive & parentArchive,
const BitInFormat & format,
const tstring & password = {} )

Constructs a BitNestedArchiveReader object of the first item in the parent archive.

Note
The constructor doesn't open the archive, it will be opened only when needed.
Parameters
libthe 7z library used.
parentArchivethe parent archive containing the nested archive.
formatthe format of the nested archive.
password(optional) the password needed for opening the nested archive.
Exceptions
BitExceptionif the format is BitFormat::Auto (automatic format detection of nested archives is not supported).

Member Function Documentation

◆ archiveProperty()

auto archiveProperty ( BitProperty property) const -> BitPropVariant

Gets the specified archive property.

Parameters
propertythe property to be retrieved.
Returns
the current value of the archive property or an empty BitPropVariant if no value is specified.

◆ clearPassword()

void clearPassword ( )
noexceptinherited

Clear the current password used by the handler.

Calling clearPassword() will disable the encryption/decryption of archives.

Note
This is equivalent to calling setPassword(L"").

◆ detectedFormat()

auto detectedFormat ( ) const -> const BitInFormat &
noexcept
Returns
the detected format of the file.

◆ extractionFormat()

auto extractionFormat ( ) const -> const BitInFormat &
noexceptinherited
Returns
the archive format used by the archive opener.

◆ extractTo() [1/2]

void extractTo ( const tstring & outDir) const

Extracts the archive to the chosen directory.

Parameters
outDirthe output directory where the extracted files will be put.

◆ extractTo() [2/2]

void extractTo ( std::map< tstring, buffer_t > & outMap) const

Extracts the content of the archive to a map of memory buffers, where the keys are the paths of the files (inside the archive), and the values are their decompressed contents.

Parameters
outMapthe output map.

◆ fileCallback()

auto fileCallback ( ) const -> const FileCallback &
inherited
Returns
the current file callback.

◆ format()

auto format ( ) const -> const BitInFormat &override
overridevirtualnoexceptinherited
Returns
the archive format used by the archive opener.

Implements BitAbstractArchiveHandler.

◆ isPasswordDefined()

auto isPasswordDefined ( ) const -> bool
noexceptinherited
Returns
a boolean value indicating whether a password is defined or not.

◆ itemProperty()

auto itemProperty ( std::uint32_t index,
BitProperty property ) const -> BitPropVariant

Gets the specified property of an item in the archive.

Parameters
indexthe index (in the archive) of the item.
propertythe property to be retrieved.
Returns
the current value of the item property or an empty BitPropVariant if the item has no value for the property.

◆ items()

auto items ( ) const -> std::vector< BitArchiveItemInfo >
Returns
a vector of all the archive items as BitArchiveItem objects.

◆ itemsCount()

auto itemsCount ( ) const -> std::uint32_t
Returns
the number of items contained in the archive.

◆ library()

auto library ( ) const -> const Bit7zLibrary &
noexceptinherited
Returns
the Bit7zLibrary object used by the handler.

◆ maxMemoryUsage()

auto maxMemoryUsage ( ) const -> std::uint64_t
noexcept
Returns
the max memory usage limit applied while extracting the parent archive.

◆ openCount()

auto openCount ( ) const -> std::size_t
Returns
the number of times the parent archive was extracted, and the nested archive was opened.

◆ overwriteMode()

auto overwriteMode ( ) const -> OverwriteMode
noexceptinherited
Returns
the current OverwriteMode.

◆ password()

auto password ( ) const -> const tstring &
inherited
Returns
the password used to open, extract, or encrypt the archive.

◆ passwordCallback()

auto passwordCallback ( ) const -> const PasswordCallback &
inherited
Returns
the current password callback.

◆ progressCallback()

auto progressCallback ( ) const -> const ProgressCallback &
inherited
Returns
the current progress callback.

◆ ratioCallback()

auto ratioCallback ( ) const -> const RatioCallback &
inherited
Returns
the current ratio callback.

◆ retainDirectories()

auto retainDirectories ( ) const -> bool
noexceptinherited
Returns
a boolean value indicating whether the directory structure must be preserved while extracting or compressing the archive.

◆ setFileCallback()

void setFileCallback ( const FileCallback & callback)
inherited

Sets the function to be called when the current file being processed changes.

Parameters
callbackthe file callback to be used.

◆ setMaxMemoryUsage()

void setMaxMemoryUsage ( std::uint64_t value)
noexcept

Sets the max memory usage limit to be used while extracting the parent archive.

Parameters
valuethe max memory limit to be used (in bytes).

◆ setOverwriteMode()

void setOverwriteMode ( OverwriteMode mode)
inherited

Sets how the handler should behave when it tries to output to an existing file or buffer.

Parameters
modethe OverwriteMode to be used by the handler.

◆ setPassword()

virtual void setPassword ( const tstring & password)
virtualinherited

Sets up a password to be used by the archive handler.

The password will be used to encrypt/decrypt archives by using the default cryptographic method of the archive format.

Note
Calling setPassword when the input archive is not encrypted does not have any effect on the extraction process.
Calling setPassword when the output format doesn't support archive encryption (e.g., GZip, BZip2, etc...) does not have any effects (in other words, it doesn't throw exceptions, and it has no effects on compression operations).
After a password has been set, it will be used for every subsequent operation. To disable the use of the password, you need to call the clearPassword method, which is equivalent to calling setPassword(L"").
Parameters
passwordthe password to be used.

Reimplemented in BitAbstractArchiveCreator.

◆ setPasswordCallback()

void setPasswordCallback ( const PasswordCallback & callback)
inherited

Sets the function to be called when a password is needed to complete the ongoing operation.

Parameters
callbackthe password callback to be used.

◆ setProgressCallback()

void setProgressCallback ( const ProgressCallback & callback)
inherited

Sets the function to be called when the processed size of the ongoing operation is updated.

Note
The completion percentage of the current operation can be obtained by calculating static_cast<int>((100.0 * processed_size) / total_size).
Parameters
callbackthe progress callback to be used.

◆ setRatioCallback()

void setRatioCallback ( const RatioCallback & callback)
inherited

Sets the function to be called when the input processed size and current output size of the ongoing operation are known.

Note
The ratio percentage of a compression operation can be obtained by calculating static_cast<int>((100.0 * output_size) / input_size).
Parameters
callbackthe ratio callback to be used.

◆ setRetainDirectories()

void setRetainDirectories ( bool retain)
noexceptinherited

Sets whether the operations' output will preserve the input's directory structure or not.

Parameters
retainthe setting for preserving or not the input directory structure

◆ setTotalCallback()

void setTotalCallback ( const TotalCallback & callback)
inherited

Sets the function to be called when the total size of an operation is available.

Parameters
callbackthe total callback to be used.

◆ test()

void test ( ) const

Tests the archive without extracting its content.

Exceptions
BitExceptionif the archive is not valid.

◆ totalCallback()

auto totalCallback ( ) const -> const TotalCallback &
inherited
Returns
the current total callback.

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