-
-
Notifications
You must be signed in to change notification settings - Fork 147
BitNestedArchiveReader
The BitNestedArchiveReader class allows reading and extracting nested archives (e.g., the tarball inside a .tar.gz archive).
#include <bit7z/bitnestedarchivereader.hpp>inherits from BitAbstractArchiveOpener.
| Return type | Name |
|---|---|
| BitNestedArchiveReader( const Bit7zLibrary& lib, const BitInputArchive& parentArchive, const BitInFormat& format, const tstring& password = {} ) | |
| BitNestedArchiveReader( const Bit7zLibrary& lib, const BitInputArchive& parentArchive, std::uint32_t index, const BitInFormat& format, const tstring& password = {} ) | |
| BitPropVariant | archiveProperty( BitProperty property ) const |
| void | clearPassword() noexcept |
| const BitInFormat & | detectedFormat() const noexcept |
| const BitInFormat & | extractionFormat() const noexcept |
| void | extractTo( const tstring& outDir ) const |
| void | extractTo( std::map< tstring, buffer_t >& outMap ) const |
| const FileCallback & | fileCallback() const |
| const BitInFormat &override | format() const noexcept |
| bool | isPasswordDefined() const noexcept |
| BitPropVariant | itemProperty( std::uint32_t index, BitProperty property ) const |
| std::vector< BitArchiveItemInfo > | items() const |
| std::uint32_t | itemsCount() const |
| const Bit7zLibrary & | library() const noexcept |
| std::uint64_t | maxMemoryUsage() const noexcept |
| std::size_t | openCount() const |
| OverwriteMode | overwriteMode() const noexcept |
| const tstring & | password() const |
| const PasswordCallback & | passwordCallback() const |
| const ProgressCallback & | progressCallback() const |
| const RatioCallback & | ratioCallback() const |
| bool | retainDirectories() const noexcept |
| void | setFileCallback( const FileCallback& callback ) |
| void | setMaxMemoryUsage( std::uint64_t value ) noexcept |
| void | setOverwriteMode( OverwriteMode mode ) |
| void | setPassword( const tstring& password ) |
| void | setPasswordCallback( const PasswordCallback& callback ) |
| void | setProgressCallback( const ProgressCallback& callback ) |
| void | setRatioCallback( const RatioCallback& callback ) |
| void | setRetainDirectories( bool retain ) noexcept |
| void | setTotalCallback( const TotalCallback& callback ) |
| void | test() const |
| const TotalCallback & | totalCallback() const |
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:
- lib: the 7z library used.
- parentArchive: the parent archive containing the nested archive.
- format: the format of the nested archive.
- password: (optional) the password needed for opening the nested archive.
Important
The function throws a BitException if the format is BitFormat::Auto (automatic format detection of nested archives is not supported).
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:
- lib: the 7z library used.
- parentArchive: the parent archive containing the nested archive.
- index: the index of the nested archive within the parent archive.
- format: the format of the nested archive.
- password: (optional) the password needed for opening the nested archive.
Important
The function throws a BitException if the format is BitFormat::Auto (automatic format detection of nested archives is not supported).
BitPropVariant archiveProperty( BitProperty property ) const
Gets the specified archive property.
Parameters:
- property: the property to be retrieved.
Returns the current value of the archive property or an empty BitPropVariant if no value is specified.
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"").
const BitInFormat & detectedFormat() const noexcept
Returns the detected format of the file.
const BitInFormat & extractionFormat() const noexcept
Returns the archive format used by the archive opener.
void extractTo( const tstring& outDir ) const
Extracts the archive to the chosen directory.
Parameters:
- outDir: the output directory where the extracted files will be put.
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:
- outMap: the output map.
const FileCallback & fileCallback() const
Returns the current file callback.
[virtual] const BitInFormat &override format() const noexcept
Returns the archive format used by the archive opener.
Returns a boolean value indicating whether a password is defined or not.
BitPropVariant itemProperty( std::uint32_t index, BitProperty property ) const
Gets the specified property of an item in the archive.
Parameters:
- index: the index (in the archive) of the item.
- property: the 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.
std::vector< BitArchiveItemInfo > items() const
Returns a vector of all the archive items as BitArchiveItem objects.
std::uint32_t itemsCount() const
Returns the number of items contained in the archive.
const Bit7zLibrary & library() const noexcept
Returns the Bit7zLibrary object used by the handler.
std::uint64_t maxMemoryUsage() const noexcept
Returns the max memory usage limit applied while extracting the parent archive.
std::size_t openCount() const
Returns the number of times the parent archive was extracted, and the nested archive was opened.
OverwriteMode overwriteMode() const noexcept
Returns the current OverwriteMode.
const tstring & password() const
Returns the password used to open, extract, or encrypt the archive.
const PasswordCallback & passwordCallback() const
Returns the current password callback.
const ProgressCallback & progressCallback() const
Returns the current progress callback.
const RatioCallback & ratioCallback() const
Returns the current ratio callback.
Returns a boolean value indicating whether the directory structure must be preserved while extracting or compressing the archive.
void setFileCallback( const FileCallback& callback )
Sets the function to be called when the current file being processed changes.
Parameters:
- callback: the file callback to be used.
void setMaxMemoryUsage( std::uint64_t value ) noexcept
Sets the max memory usage limit to be used while extracting the parent archive.
Parameters:
- value: the max memory limit to be used (in bytes).
void setOverwriteMode( OverwriteMode mode )
Sets how the handler should behave when it tries to output to an existing file or buffer.
Parameters:
- mode: the OverwriteMode to be used by the handler.
[virtual] void setPassword( const tstring& password )
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.
Note
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).
Note
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:
- password: the password to be used.
void setPasswordCallback( const PasswordCallback& callback )
Sets the function to be called when a password is needed to complete the ongoing operation.
Parameters:
- callback: the password callback to be used.
void setProgressCallback( const ProgressCallback& callback )
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:
- callback: the progress callback to be used.
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.
Note
The ratio percentage of a compression operation can be obtained by calculating static_cast<int>((100.0 * output_size) / input_size).
Parameters:
- callback: the ratio callback to be used.
Sets whether the operations' output will preserve the input's directory structure or not.
Parameters:
- retain: the setting for preserving or not the input directory structure
void setTotalCallback( const TotalCallback& callback )
Sets the function to be called when the total size of an operation is available.
Parameters:
- callback: the total callback to be used.
Tests the archive without extracting its content.
Important
The function throws a BitException if the archive is not valid.
const TotalCallback & totalCallback() const
Returns the current total callback.
Copyright © Riccardo Ostani (@rikyoz)
- Bit7zLibrary
- BitArchiveEditor
- BitArchiveReader
- BitArchiveWriter
- BitException
- BitFileCompressor
- BitFileExtractor
- BitMemCompressor
- BitMemExtractor
- BitNestedArchiveReader
- BitStreamCompressor
- BitStreamExtractor
- BitInFormat