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

The BitArchiveReader class allows reading metadata of archives, as well as extracting them. More...

#include <bit7z/bitarchivereader.hpp>

Inheritance diagram for BitArchiveReader:
Collaboration diagram for BitArchiveReader:

Public Member Functions

 BitArchiveReader (const Bit7zLibrary &lib, buffer_t &&inArchive, ArchiveStartOffset archiveStart, const BitInFormat &format=BitFormat::Auto, const tstring &password={})=delete
 Deleted overload preventing the use of a temporary input buffer.
 BitArchiveReader (const Bit7zLibrary &lib, buffer_t &&inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})=delete
 Deleted overload preventing the use of a temporary input buffer.
 BitArchiveReader (const Bit7zLibrary &lib, const BitInputArchive &inArchive, ArchiveStartOffset archiveStart, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the main subfile of the given archive.
 BitArchiveReader (const Bit7zLibrary &lib, const BitInputArchive &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the main subfile of the given archive.
 BitArchiveReader (const Bit7zLibrary &lib, const BitInputArchive &inArchive, std::uint32_t subfileIndex, ArchiveStartOffset archiveStart, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the subfile at the specified index of the given archive.
 BitArchiveReader (const Bit7zLibrary &lib, const BitInputArchive &inArchive, std::uint32_t subfileIndex, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the subfile at the specified index of the given archive.
 BitArchiveReader (const Bit7zLibrary &lib, const buffer_t &inArchive, ArchiveStartOffset archiveStart, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the archive in the input buffer.
 BitArchiveReader (const Bit7zLibrary &lib, const buffer_t &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the archive in the input buffer.
 BitArchiveReader (const Bit7zLibrary &lib, const tstring &inArchive, ArchiveStartOffset archiveStart, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the input file archive.
 BitArchiveReader (const Bit7zLibrary &lib, const tstring &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the input file archive.
 BitArchiveReader (const Bit7zLibrary &lib, std::istream &inArchive, ArchiveStartOffset archiveStart, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the archive from the standard input stream.
 BitArchiveReader (const Bit7zLibrary &lib, std::istream &inArchive, const BitInFormat &format=BitFormat::Auto, const tstring &password={})
 Constructs a BitArchiveReader object, opening the archive from the standard input stream.
 ~BitArchiveReader () override=default
 BitArchiveReader destructor.
auto archiveHasPath () const noexcept -> bool
auto archivePath () const noexcept -> const tstring &
auto archiveProperties () const -> std::map< BitProperty, BitPropVariant >
auto archiveProperty (BitProperty property) const -> BitPropVariant
 Gets the specified archive property.
auto begin () const noexcept -> BitInputArchive::ConstIterator
auto cbegin () const noexcept -> BitInputArchive::ConstIterator
auto cend () const noexcept -> BitInputArchive::ConstIterator
void clearPassword () noexcept
 Clear the current password used by the handler.
auto contains (const tstring &path) const noexcept -> bool
 Find if there is an item in the archive that has the given path.
auto detectedFormat () const noexcept -> const BitInFormat &
auto end () const noexcept -> BitInputArchive::ConstIterator
void extractFolderTo (const tstring &outDir, const tstring &folderPath, FolderPathPolicy policy=FolderPathPolicy::Strip) const
 Extracts a folder from the archive to the chosen directory.
auto extractionFormat () const noexcept -> const BitInFormat &
void extractMatchingRegexTo (buffer_t &outBuffer, const tstring &regex, FilterPolicy policy=FilterPolicy::Include) const
 Extracts to the output buffer the first file in the archive that matches the given regex pattern.
void extractMatchingRegexTo (const tstring &outDir, const tstring &regex, FilterPolicy policy=FilterPolicy::Include) const
 Extracts to the output directory all the items whose paths match the given regex pattern.
void extractMatchingTo (buffer_t &outBuffer, const tregex &regex, FilterPolicy policy=FilterPolicy::Include) const
 Extracts to the output buffer the first file in the archive that matches the given regex pattern.
void extractMatchingTo (buffer_t &outBuffer, const tstring &itemFilter, FilterPolicy policy=FilterPolicy::Include) const
 Extracts to the output buffer the first file whose path matches the given wildcard pattern.
void extractMatchingTo (const tstring &outDir, const tregex &regex, FilterPolicy policy=FilterPolicy::Include) const
 Extracts to the output directory all the items whose paths match the given regex pattern.
void extractMatchingTo (const tstring &outDir, const tstring &itemFilter, FilterPolicy policy=FilterPolicy::Include) const
 Extracts to the output directory all the items whose paths match the given wildcard pattern.
void extractRootFolderContentTo (const tstring &outDir) const
 Extracts the content of the archive's root folder to the chosen directory.
void extractTo (buffer_t &outBuffer, FilterCallback filterCallback) const
 Extracts to the output buffer the first item satisfying the given filtering criteria.
void extractTo (buffer_t &outBuffer, std::uint32_t index=0) const
 Extracts a file to the output buffer.
void extractTo (BufferCallback callback, BitIndicesView indices={}) const
 Extracts the content of the archive to the buffers provided by the given BufferCallback.
void extractTo (byte_t *outBuffer, std::size_t size, std::uint32_t index=0) const
 Extracts a file to the pre-allocated output buffer.
template<std::size_t N>
void extractTo (byte_t(&outBuffer)[N], std::uint32_t index=0) const
 Extracts a file to the pre-allocated output buffer.
void extractTo (const tstring &outDir, BitIndicesView indices={}) const
 Extracts the specified items to the chosen directory.
void extractTo (const tstring &outDir, FilterCallback filterCallback) const
 Extracts to the output directory all the items that satisfy the given filtering criteria.
void extractTo (const tstring &outDir, RenameCallback renameCallback) const
 Extracts the archive to the chosen directory, specifying the names of the extracted items via a RenameCallback.
void extractTo (RawDataCallback callback, BitIndicesView indices={}) const
 Extracts the raw content of the archive to the given callback.
template<std::size_t N>
void extractTo (std::array< byte_t, N > &outBuffer, std::uint32_t index=0) const
 Extracts a file to the pre-allocated output buffer.
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.
void extractTo (std::ostream &outStream, std::uint32_t index=0) const
 Extracts a file to the output stream.
auto fileCallback () const -> const FileCallback &
auto filesCount () const -> std::uint32_t
auto find (const tstring &path) const noexcept -> BitInputArchive::ConstIterator
 Find an item in the archive that has the given path.
auto findByName (const tstring &name) const noexcept -> BitInputArchive::ConstIterator
 Find an item in the archive that has the given name (last component of its path within the archive).
auto foldersCount () const -> std::uint32_t
auto format () const noexcept -> const BitInFormat &override
auto handler () const noexcept -> const BitAbstractArchiveHandler &
auto hasEncryptedItems () const -> bool
auto isEncrypted () const -> bool
auto isItemEncrypted (std::uint32_t index) const -> bool
auto isItemFolder (std::uint32_t index) const -> bool
auto isMultiVolume () const -> bool
auto isPasswordDefined () const noexcept -> bool
auto isSolid () const -> bool
auto itemAt (std::uint32_t index) const -> BitArchiveItemOffset
 Retrieve the item at the given index.
auto itemHasProperty (std::uint32_t index, BitProperty property) const -> bool
 Checks whether the item at the given index has the specified property.
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 itemsMatching (const tstring &pattern) const -> std::vector< BitArchiveItemInfo >
 Gets the items whose paths match the given wildcard pattern.
auto library () const noexcept -> const Bit7zLibrary &
auto mainSubfileIndex () const -> std::uint32_t
auto overwriteMode () const noexcept -> OverwriteMode
auto packSize () const -> std::uint64_t
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
auto rootFolder () const -> tstring
 Returns the single top-level folder that contains all of the archive's items.
void setFileCallback (const FileCallback &callback)
 Sets the function to be called when the current file being processed changes.
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.
auto size () const -> std::uint64_t
void test (BitIndicesView indices={}) const
 Tests the archive without extracting its content.
void testItem (std::uint32_t index) const
 Tests the archive item at the given index without extracting it.
auto totalCallback () const -> const TotalCallback &
void useFormatProperty (const wchar_t *name, const BitPropVariant &property) const
 Use the given format property to read the archive.
template<typename T, typename = typename std::enable_if< is_explicitly_convertible< T, BitPropVariant >::value >::type>
void useFormatProperty (const wchar_t *name, T &&value) const
 Use the given format property to read the archive.
auto volumesCount () const -> std::uint32_t

Static Public Member Functions

template<typename T>
static auto isEncrypted (const Bit7zLibrary &lib, T &&inArchive, const BitInFormat &format=BitFormat::Auto) noexcept -> bool
 Checks if the given archive contains only encrypted items.
template<typename T>
static auto isHeaderEncrypted (const Bit7zLibrary &lib, T &&inArchive, const BitInFormat &format=BitFormat::Auto) noexcept -> bool
 Checks if the given archive is header-encrypted or not.

Detailed Description

The BitArchiveReader class allows reading metadata of archives, as well as extracting them.

Constructor & Destructor Documentation

◆ BitArchiveReader() [1/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const tstring & inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the input file archive.

Note
When bit7z is compiled using the BIT7Z_AUTO_FORMAT option, the format argument has the default value BitFormat::Auto (automatic format detection of the input archive). On the contrary, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified.
Parameters
libthe 7z library used.
inArchivethe path to the archive to be read.
archiveStartwhether to search for the archive's start throughout the entire file or only at the beginning.
formatthe format of the input archive.
password(optional) the password needed for opening the input archive.

◆ BitArchiveReader() [2/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const tstring & inArchive,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the input file archive.

Note
When bit7z is compiled using the BIT7Z_AUTO_FORMAT option, the format argument has the default value BitFormat::Auto (automatic format detection of the input archive). On the contrary, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified.
Parameters
libthe 7z library used.
inArchivethe path to the archive to be read.
formatthe format of the input archive.
password(optional) the password needed for opening the input archive.

◆ BitArchiveReader() [3/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const buffer_t & inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the archive in the input buffer.

Note
When bit7z is compiled using the BIT7Z_AUTO_FORMAT option, the format argument has the default value BitFormat::Auto (automatic format detection of the input archive). On the contrary, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified.
Parameters
libthe 7z library used.
inArchivethe input buffer containing the archive to be read.
archiveStartwhether to search for the archive's start throughout the entire file or only at the beginning.
formatthe format of the input archive.
password(optional) the password needed for opening the input archive.

◆ BitArchiveReader() [4/12]

BitArchiveReader ( const Bit7zLibrary & lib,
buffer_t && inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )
delete

Deleted overload preventing the use of a temporary input buffer.

The reader keeps the archive open and reads the buffer on later extraction, so the buffer must outlive the BitArchiveReader; a temporary would dangle.

◆ BitArchiveReader() [5/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const buffer_t & inArchive,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the archive in the input buffer.

Note
When bit7z is compiled using the BIT7Z_AUTO_FORMAT option, the format argument has the default value BitFormat::Auto (automatic format detection of the input archive). On the contrary, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified.
Parameters
libthe 7z library used.
inArchivethe input buffer containing the archive to be read.
formatthe format of the input archive.
password(optional) the password needed for opening the input archive.

◆ BitArchiveReader() [6/12]

BitArchiveReader ( const Bit7zLibrary & lib,
buffer_t && inArchive,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )
delete

Deleted overload preventing the use of a temporary input buffer.

The reader keeps the archive open and reads the buffer on later extraction, so the buffer must outlive the BitArchiveReader; a temporary would dangle.

◆ BitArchiveReader() [7/12]

BitArchiveReader ( const Bit7zLibrary & lib,
std::istream & inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the archive from the standard input stream.

Note
When bit7z is compiled using the BIT7Z_AUTO_FORMAT option, the format argument has the default value BitFormat::Auto (automatic format detection of the input archive). On the contrary, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified.
Parameters
libthe 7z library used.
inArchivethe standard input stream of the archive to be read.
archiveStartwhether to search for the archive's start throughout the entire file or only at the beginning.
formatthe format of the input archive.
password(optional) the password needed for opening the input archive.

◆ BitArchiveReader() [8/12]

BitArchiveReader ( const Bit7zLibrary & lib,
std::istream & inArchive,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the archive from the standard input stream.

Note
When bit7z is compiled using the BIT7Z_AUTO_FORMAT option, the format argument has the default value BitFormat::Auto (automatic format detection of the input archive). On the contrary, when BIT7Z_AUTO_FORMAT is not defined (i.e., no auto format detection available), the format argument must be specified.
Parameters
libthe 7z library used.
inArchivethe standard input stream of the archive to be read.
formatthe format of the input archive.
password(optional) the password needed for opening the input archive.

◆ BitArchiveReader() [9/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const BitInputArchive & inArchive,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the main subfile of the given archive.

Note
The constructor will throw an exception if the format of the input archive doesn't have a main subfile.
Parameters
libthe 7z library used.
inArchivethe input archive containing a main subfile.
formatthe format of the main subfile.
password(optional) the password needed for opening the main subfile.
Exceptions
BitExceptionif the format of the input archive doesn't have a main subfile.

◆ BitArchiveReader() [10/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const BitInputArchive & inArchive,
ArchiveStartOffset archiveStart,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the main subfile of the given archive.

Note
The constructor will throw an exception if the format of the input archive doesn't have a main subfile.
Parameters
libthe 7z library used.
inArchivethe input archive containing a main subfile.
archiveStartwhether to search for the archive's start throughout the entire subfile stream or only at the beginning.
formatthe format of the main subfile.
password(optional) the password needed for opening the main subfile.
Exceptions
BitExceptionif the format of the input archive doesn't have a main subfile.

◆ BitArchiveReader() [11/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const BitInputArchive & inArchive,
std::uint32_t subfileIndex,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the subfile at the specified index of the given archive.

Parameters
libthe 7z library used.
inArchivethe input archive containing the desired subfile.
subfileIndexthe index of the subfile within the input archive.
formatthe format of the subfile.
password(optional) the password needed for opening the subfile.
Exceptions
BitExceptionif the format of the input archive doesn't support subfile streams.

◆ BitArchiveReader() [12/12]

BitArchiveReader ( const Bit7zLibrary & lib,
const BitInputArchive & inArchive,
std::uint32_t subfileIndex,
ArchiveStartOffset archiveStart,
const BitInFormat & format = BitFormat::Auto,
const tstring & password = {} )

Constructs a BitArchiveReader object, opening the subfile at the specified index of the given archive.

Parameters
libthe 7z library used.
inArchivethe input archive containing the desired subfile.
subfileIndexthe index of the subfile within the input archive.
archiveStartwhether to search for the archive's start throughout the entire subfile stream or only at the beginning.
formatthe format of the subfile.
password(optional) the password needed for opening the subfile.
Exceptions
BitExceptionif the format of the input archive doesn't support subfile streams.

◆ ~BitArchiveReader()

~BitArchiveReader ( )
overridedefault

BitArchiveReader destructor.

Note
It releases the input archive file.

Member Function Documentation

◆ archiveHasPath()

auto archiveHasPath ( ) const -> bool
noexceptinherited
Returns
whether the archive has a path (i.e., filesystem archive), or not (e.g., buffer archive).

◆ archivePath()

auto archivePath ( ) const -> const tstring &
noexceptinherited
Returns
the path to the archive (the empty string for buffer/stream archives).

◆ archiveProperties()

auto archiveProperties ( ) const -> std::map< BitProperty, BitPropVariant >
Returns
a map of all the available (i.e., non-empty) archive properties and their respective values.

◆ archiveProperty()

auto archiveProperty ( BitProperty property) const -> BitPropVariant
inherited

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.

◆ begin()

auto begin ( ) const -> BitInputArchive::ConstIterator
noexceptinherited
Returns
an iterator to the first element of the archive; if the archive is empty, the returned iterator will be equal to the end() iterator.

◆ cbegin()

auto cbegin ( ) const -> BitInputArchive::ConstIterator
noexceptinherited
Returns
an iterator to the first element of the archive; if the archive is empty, the returned iterator will be equal to the end() iterator.

◆ cend()

auto cend ( ) const -> BitInputArchive::ConstIterator
noexceptinherited
Returns
an iterator to the element following the last element of the archive; this element acts as a placeholder: attempting to access it results in undefined behavior.

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

◆ contains()

auto contains ( const tstring & path) const -> bool
noexceptinherited

Find if there is an item in the archive that has the given path.

Parameters
paththe path to be searched in the archive.
Returns
true if and only if an item with the given path exists in the archive.

◆ detectedFormat()

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

◆ end()

auto end ( ) const -> BitInputArchive::ConstIterator
noexceptinherited
Returns
an iterator to the element following the last element of the archive; this element acts as a placeholder: attempting to access it results in undefined behavior.

◆ extractFolderTo()

void extractFolderTo ( const tstring & outDir,
const tstring & folderPath,
FolderPathPolicy policy = FolderPathPolicy::Strip ) const
inherited

Extracts a folder from the archive to the chosen directory.

Parameters
outDirthe output directory where the extracted folder will be put.
folderPaththe path of the folder inside the archive to be extracted.
policy(optional) the path policy to be used for extracting the folder.

◆ extractionFormat()

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

◆ extractMatchingRegexTo() [1/2]

void extractMatchingRegexTo ( buffer_t & outBuffer,
const tstring & regex,
FilterPolicy policy = FilterPolicy::Include ) const
inherited

Extracts to the output buffer the first file in the archive that matches the given regex pattern.

Note
Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define.
Parameters
outBufferthe output buffer where the extracted file will be put.
regexthe regex used for matching the paths of files inside the archive.
policy(optional) the filtering policy to be applied to the matched items.

◆ extractMatchingRegexTo() [2/2]

void extractMatchingRegexTo ( const tstring & outDir,
const tstring & regex,
FilterPolicy policy = FilterPolicy::Include ) const
inherited

Extracts to the output directory all the items whose paths match the given regex pattern.

Note
Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define.
Parameters
outDirthe output directory where extracted files will be put.
regexthe regex used for matching the paths of files inside the archive.
policy(optional) the filtering policy to be applied to the matching items.

◆ extractMatchingTo() [1/4]

void extractMatchingTo ( buffer_t & outBuffer,
const tregex & regex,
FilterPolicy policy = FilterPolicy::Include ) const
inherited

Extracts to the output buffer the first file in the archive that matches the given regex pattern.

Note
Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define.
Parameters
outBufferthe output buffer where the extracted file will be put.
regexthe regex used for matching the paths of files inside the archive.
policy(optional) the filtering policy to be applied to the matched items.

◆ extractMatchingTo() [2/4]

void extractMatchingTo ( buffer_t & outBuffer,
const tstring & itemFilter,
FilterPolicy policy = FilterPolicy::Include ) const
inherited

Extracts to the output buffer the first file whose path matches the given wildcard pattern.

Parameters
outBufferthe output buffer where to extract the file.
itemFilterthe wildcard pattern used for matching the paths of files inside the archive.
policy(optional) the filtering policy to be applied to the matched items.

◆ extractMatchingTo() [3/4]

void extractMatchingTo ( const tstring & outDir,
const tregex & regex,
FilterPolicy policy = FilterPolicy::Include ) const
inherited

Extracts to the output directory all the items whose paths match the given regex pattern.

Note
Available only when compiling bit7z using the BIT7Z_REGEX_MATCHING preprocessor define.
Parameters
outDirthe output directory where extracted files will be put.
regexthe regex used for matching the paths of files inside the archive.
policy(optional) the filtering policy to be applied to the matching items.

◆ extractMatchingTo() [4/4]

void extractMatchingTo ( const tstring & outDir,
const tstring & itemFilter,
FilterPolicy policy = FilterPolicy::Include ) const
inherited

Extracts to the output directory all the items whose paths match the given wildcard pattern.

Parameters
outDirthe output directory where extracted files will be put.
itemFilterthe wildcard pattern used for matching the paths of items inside the archive.
policy(optional) the filtering policy to be applied to the matching items.

◆ extractRootFolderContentTo()

void extractRootFolderContentTo ( const tstring & outDir) const
inherited

Extracts the content of the archive's root folder to the chosen directory.

The archive's root folder is the single top-level folder shared by all the items in the archive; its name is stripped from the extracted items' paths.

Note
If the archive does not have a single root folder, a BitException is thrown.
Parameters
outDirthe output directory where the root folder's content will be put.

◆ extractTo() [1/12]

void extractTo ( buffer_t & outBuffer,
FilterCallback filterCallback ) const
inherited

Extracts to the output buffer the first item satisfying the given filtering criteria.

Parameters
outBufferthe output buffer where the extracted file will be put.
filterCallbackthe filtering callback that specifies whether to extract an item or not.

◆ extractTo() [2/12]

void extractTo ( buffer_t & outBuffer,
std::uint32_t index = 0 ) const
inherited

Extracts a file to the output buffer.

Parameters
outBufferthe output buffer where the content of the archive will be put.
index(optional) the index of the file to be extracted.

◆ extractTo() [3/12]

void extractTo ( BufferCallback callback,
BitIndicesView indices = {} ) const
inherited

Extracts the content of the archive to the buffers provided by the given BufferCallback.

Parameters
callbackthe function providing the buffers.
indices(optional) the indices of the files in the archive that must be extracted.

◆ extractTo() [4/12]

void extractTo ( byte_t * outBuffer,
std::size_t size,
std::uint32_t index = 0 ) const
inherited

Extracts a file to the pre-allocated output buffer.

Parameters
outBufferthe pre-allocated output buffer.
sizethe size of the output buffer (it must be equal to the unpacked size of the item to be extracted).
indexthe index of the file to be extracted.

◆ extractTo() [5/12]

template<std::size_t N>
void extractTo ( byte_t(&) outBuffer[N],
std::uint32_t index = 0 ) const
inlineinherited

Extracts a file to the pre-allocated output buffer.

Template Parameters
Nthe size of the output buffer (it must be equal to the unpacked size of the item to be extracted).
Parameters
outBufferthe pre-allocated output buffer.
indexthe index of the file to be extracted.

◆ extractTo() [6/12]

void extractTo ( const tstring & outDir,
BitIndicesView indices = {} ) const
inherited

Extracts the specified items to the chosen directory.

Parameters
outDirthe output directory where the extracted files will be put.
indices(optional) the indices of the files in the archive that must be extracted.

◆ extractTo() [7/12]

void extractTo ( const tstring & outDir,
FilterCallback filterCallback ) const
inherited

Extracts to the output directory all the items that satisfy the given filtering criteria.

Parameters
outDirthe output directory where extracted files will be put.
filterCallbackthe filtering callback that specifies whether to extract an item or not.

◆ extractTo() [8/12]

void extractTo ( const tstring & outDir,
RenameCallback renameCallback ) const
inherited

Extracts the archive to the chosen directory, specifying the names of the extracted items via a RenameCallback.

Note
The callback receives the archive item being extracted and must return the path that the extracted item must have on the filesystem. If the path of the item must not change, simply return the item's path in the callback. If the item must not be extracted, return an empty string in the callback.
Parameters
outDirthe output directory where the extracted files will be put.
renameCallbackthe callback that returns the names for the extracted files.

◆ extractTo() [9/12]

void extractTo ( RawDataCallback callback,
BitIndicesView indices = {} ) const
inherited

Extracts the raw content of the archive to the given callback.

Note
You can set a FileCallback to check the file being extracted.
Parameters
callbacka function providing the extracted raw data to the user.
indices(optional) the indices of the files in the archive that must be extracted.

◆ extractTo() [10/12]

template<std::size_t N>
void extractTo ( std::array< byte_t, N > & outBuffer,
std::uint32_t index = 0 ) const
inlineinherited

Extracts a file to the pre-allocated output buffer.

Template Parameters
Nthe size of the output buffer (it must be equal to the unpacked size of the item to be extracted).
Parameters
outBufferthe pre-allocated output buffer.
indexthe index of the file to be extracted.

◆ extractTo() [11/12]

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

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.

◆ extractTo() [12/12]

void extractTo ( std::ostream & outStream,
std::uint32_t index = 0 ) const
inherited

Extracts a file to the output stream.

Parameters
outStreamthe (binary) stream where the content of the archive will be put.
indexthe index of the file to be extracted.

◆ fileCallback()

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

◆ filesCount()

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

◆ find()

auto find ( const tstring & path) const -> BitInputArchive::ConstIterator
noexceptinherited

Find an item in the archive that has the given path.

Parameters
paththe path to be searched in the archive.
Returns
an iterator to the item with the given path, or an iterator equal to the end() iterator if no item is found.

◆ findByName()

auto findByName ( const tstring & name) const -> BitInputArchive::ConstIterator
noexceptinherited

Find an item in the archive that has the given name (last component of its path within the archive).

Parameters
namethe name to be searched in the archive.
Returns
an iterator to the item with the given name, or an iterator equal to the end() iterator if no item is found.

◆ foldersCount()

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

◆ format()

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

Implements BitAbstractArchiveHandler.

◆ handler()

auto handler ( ) const -> const BitAbstractArchiveHandler &
noexceptinherited
Returns
the BitAbstractArchiveHandler object containing the settings for reading the archive.

◆ hasEncryptedItems()

auto hasEncryptedItems ( ) const -> bool
Returns
true if and only if the archive has at least one encrypted item.

◆ isEncrypted() [1/2]

auto isEncrypted ( ) const -> bool
Returns
true if and only if the archive has only encrypted items.

◆ isEncrypted() [2/2]

template<typename T>
auto isEncrypted ( const Bit7zLibrary & lib,
T && inArchive,
const BitInFormat & format = BitFormat::Auto ) -> bool
inlinestaticnoexcept

Checks if the given archive contains only encrypted items.

Note
A header-encrypted archive is also encrypted, but the contrary is not generally true.
An archive might contain both plain and encrypted files; in this case, this function will return false.
Template Parameters
TThe input type of the archive (i.e., file path, buffer, or standard stream).
Parameters
libthe 7z library used.
inArchivethe archive to be read.
formatthe format of the input archive.
Returns
true if and only if the archive has only encrypted items.

◆ isHeaderEncrypted()

template<typename T>
auto isHeaderEncrypted ( const Bit7zLibrary & lib,
T && inArchive,
const BitInFormat & format = BitFormat::Auto ) -> bool
inlinestaticnoexcept

Checks if the given archive is header-encrypted or not.

Template Parameters
TThe input type of the archive (i.e., file path, buffer, or standard stream).
Parameters
libthe 7z library used.
inArchivethe archive to be read.
formatthe format of the input archive.
Returns
true if and only if the archive has at least one encrypted item.

◆ isItemEncrypted()

auto isItemEncrypted ( std::uint32_t index) const -> bool
inherited
Parameters
indexthe index of an item in the archive.
Returns
true if and only if the item at the given index is encrypted.

◆ isItemFolder()

auto isItemFolder ( std::uint32_t index) const -> bool
inherited
Parameters
indexthe index of an item in the archive.
Returns
true if and only if the item at the given index is a folder.

◆ isMultiVolume()

auto isMultiVolume ( ) const -> bool
Returns
true if and only if the archive is composed by multiple volumes.

◆ isPasswordDefined()

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

◆ isSolid()

auto isSolid ( ) const -> bool
Returns
true if and only if the archive was created using solid compression.

◆ itemAt()

auto itemAt ( std::uint32_t index) const -> BitArchiveItemOffset
inherited

Retrieve the item at the given index.

Parameters
indexthe index of the item to be retrieved.
Returns
the item at the given index within the archive.

◆ itemHasProperty()

auto itemHasProperty ( std::uint32_t index,
BitProperty property ) const -> bool
inherited

Checks whether the item at the given index has the specified property.

Parameters
indexthe index (in the archive) of the item.
propertythe property to be checked for existence.
Returns
true if the item has the property, false otherwise.

◆ itemProperty()

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

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
inherited
Returns
the number of items contained in the archive.

◆ itemsMatching()

auto itemsMatching ( const tstring & pattern) const -> std::vector< BitArchiveItemInfo >

Gets the items whose paths match the given wildcard pattern.

Parameters
patterna wildcard pattern.
Returns
the items whose paths match the given wildcard pattern.

◆ library()

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

◆ mainSubfileIndex()

auto mainSubfileIndex ( ) const -> std::uint32_t
inherited
Returns
the index of the main subfile of the archive, if any.
Exceptions
BitExceptionif the archive format doesn't have a main subfile.

◆ overwriteMode()

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

◆ packSize()

auto packSize ( ) const -> std::uint64_t
Returns
the total compressed size of the archive content.

◆ 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.

◆ rootFolder()

auto rootFolder ( ) const -> tstring
inherited

Returns the single top-level folder that contains all of the archive's items.

The archive is considered to have a root folder only when every item is contained within the same top-level folder. There is no common root folder if the items belong to different top-level folders, if the archive contains a file at its root, or if the archive is empty.

Note
The returned value is the folder's name, without any trailing path separator.
Returns
the name of the archive's root folder, or an empty string if the archive does not have a single common root folder.

◆ 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.

◆ 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.

◆ size()

auto size ( ) const -> std::uint64_t
Returns
the total uncompressed size of the archive content.

◆ test()

void test ( BitIndicesView indices = {}) const
inherited

Tests the archive without extracting its content.

Parameters
indices(optional) the indices of the items to be tested.
Exceptions
BitExceptionif the archive is not valid.

◆ testItem()

void testItem ( std::uint32_t index) const
inherited

Tests the archive item at the given index without extracting it.

Parameters
indexthe index of the item to be tested.
Exceptions
BitExceptionif the index is not valid, or the item at the given index is not valid, or the whole archive is not valid.

◆ totalCallback()

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

◆ useFormatProperty() [1/2]

void useFormatProperty ( const wchar_t * name,
const BitPropVariant & property ) const
inherited

Use the given format property to read the archive.

Parameters
namethe name of the property.
propertythe property value.

◆ useFormatProperty() [2/2]

template<typename T, typename = typename std::enable_if< is_explicitly_convertible< T, BitPropVariant >::value >::type>
void useFormatProperty ( const wchar_t * name,
T && value ) const
inlineinherited

Use the given format property to read the archive.

Template Parameters
Tthe type of the property.
Parameters
namethe name of the property.
valuethe property value.

◆ volumesCount()

auto volumesCount ( ) const -> std::uint32_t
Returns
the number of volumes composing the archive.

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