Skip to content

BitExtractor

Oz edited this page Sep 3, 2019 · 15 revisions

The BitExtractor class allows to extract the content of file archives.

#include "bitextractor.hpp"

inherits from BitArchiveOpener.

List of all members

Public Members

Return type Name
BitExtractor( const Bit7zLibrary &lib, const BitInFormat &format=BitFormat::Auto )
void extract( const wstring &in_file, const wstring &out_dir=L"" ) const
void extractMatching( const wstring &in_file, const wstring &item_filter, const wstring &out_dir=L"" ) const
void extractMatchingRegex( const wstring &in_file, const wstring &regex, const wstring &out_dir ) const
void extractItems( const wstring &in_file, const vector< uint32_t > &indices, const wstring &out_dir=L"" ) const
void extract( const wstring &in_file, vector< byte_t > &out_buffer, unsigned int index=0 ) const
void extract( const wstring &in_file, ostream &out_stream, unsigned int index=0 ) const
void extract( const wstring &in_file, map< wstring, vector< byte_t > > &out_map ) const
void test( const wstring &in_file ) const
const BitInFormat & format() const override
const BitInFormat & extractionFormat() const
const Bit7zLibrary & library() const
const wstring password() const
bool isPasswordDefined() const
TotalCallback totalCallback() const
ProgressCallback progressCallback() const
RatioCallback ratioCallback() const
FileCallback fileCallback() const
PasswordCallback passwordCallback() const
void setPassword( const wstring &password )
void clearPassword()
void setTotalCallback( const TotalCallback &callback )
void setProgressCallback( const ProgressCallback &callback )
void setRatioCallback( const RatioCallback &callback )
void setFileCallback( const FileCallback &callback )
void setPasswordCallback( const PasswordCallback &callback )

Member Function Documentation

BitExtractor( const Bit7zLibrary &lib, const BitInFormat &format=BitFormat::Auto )

Constructs a BitExtractor object.

The Bit7zLibrary parameter is needed in order to have access to the functionalities of the 7z DLLs. On the other hand, the BitInFormat is required in order to know the format of the input archive.

Note: When bit7z is compiled using the BIT7Z_AUTO_FORMAT macro define, the format argument has default value BitFormat::Auto (automatic format detection of the input archive). On the other hand, when BIT7Z_AUTO_FORMAT is not defined (i.e. no auto format detection available) the format argument must be specified.


void extract( const wstring &in_file, const wstring &out_dir=L"" ) const

Extracts the given archive into the choosen directory.


void extractMatching( const wstring &in_file, const wstring &item_filter, const wstring &out_dir=L"" ) const

Extracts the wildcard matching files in the given archive into the choosen directory.


void extractMatchingRegex( const wstring &in_file, const wstring &regex, const wstring &out_dir ) const

Extracts the regex matching files in the given archive into the choosen directory.

Note: Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define.


void extractItems( const wstring &in_file, const vector< uint32_t > &indices, const wstring &out_dir=L"" ) const

Extracts the specified items in the given archive into the choosen directory.


void extract( const wstring &in_file, vector< byte_t > &out_buffer, unsigned int index=0 ) const

Extracts a file from the given archive into the output buffer.


void extract( const wstring &in_file, ostream &out_stream, unsigned int index=0 ) const

Extracts a file from the given archive into the output stream.


void extract( const wstring &in_file, map< wstring, vector< byte_t > > &out_map ) const

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


void test( const wstring &in_file ) const

Tests the given archive without extracting its content.

If the input archive is not valid, a BitException is thrown!


[virtual] const BitInFormat & format() const override

Returns the archive format used by the archive opener.


const BitInFormat & extractionFormat() const

Returns the archive format used by the archive opener.


const Bit7zLibrary & library() const

Returns the Bit7zLibrary object used by the handler.


const wstring password() const

Returns the password used to open, extract or encrypt the archive.


bool isPasswordDefined() const

Returns true if a password is defined, false otherwise.


TotalCallback totalCallback() const

Returns the current total callback.


ProgressCallback progressCallback() const

Returns the current progress callback.


RatioCallback ratioCallback() const

Returns the current ratio callback.


FileCallback fileCallback() const

Returns the current file callback.


PasswordCallback passwordCallback() const

Returns the current password callback.


[virtual] void setPassword( const wstring &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 effect on the extraction process.


void clearPassword()

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"").


void setTotalCallback( const TotalCallback &callback )

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


void setProgressCallback( const ProgressCallback &callback )

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

Note: The percentage of completition of the current operation can be obtained by calculating static_cast( ( 100.0 * processed_size ) / total_size ).


void setRatioCallback( const RatioCallback &callback )

Sets the callback 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( ( 100.0 * output_size ) / input_size ).


void setFileCallback( const FileCallback &callback )

Sets the callback to be called when the currently file being processed changes.


void setPasswordCallback( const PasswordCallback &callback )

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


Clone this wiki locally