Class BitExtractor

Synopsis

#include <include/bitextractor.hpp>

class BitExtractor : public BitArchiveOpener

Description

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

Mentioned in

Inheritance

Ancestors: BitArchiveOpener

Methods

BitExtractorConstructs a BitExtractor object.
extract OverloadExtracts the given archive into the choosen directory.
extract OverloadExtracts a file from the given archive into the output buffer.
extract OverloadExtracts a file from the given archive into the output stream.
extract OverloadExtracts 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.
extractItemsExtracts the specified items in the given archive into the choosen directory.
extractMatchingExtracts the wildcard matching files in the given archive into the choosen directory.
extractMatchingRegexExtracts the regex matching files in the given archive into the choosen directory.
testTests the given archive without extracting its content.

Source

Lines 33-136 in include/bitextractor.hpp.

class BitExtractor : public BitArchiveOpener {
    public:
        /**
         * @brief 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.
         *
         * @param lib       the 7z library used.
         * @param format    the input archive format.
         */
        explicit BitExtractor( const Bit7zLibrary& lib, const BitInFormat& format DEFAULT_FORMAT );
        /**
         * @brief Extracts the given archive into the choosen directory.
         *
         * @param in_file       the input archive file.
         * @param out_dir       the output directory where extracted files will be put.
         */
        void extract( const wstring& in_file, const wstring& out_dir = L"" ) const;
        /**
         * @brief Extracts the wildcard matching files in the given archive into the choosen directory.
         *
         * @param in_file       the input archive file.
         * @param item_filter   the wildcard pattern used for matching the paths of files inside the archive.
         * @param out_dir       the output directory where extracted files will be put.
         */
        void extractMatching( const wstring& in_file,
                              const wstring& item_filter,
                              const wstring& out_dir = L"" ) const;
ef BIT7Z_REGEX_MATCHING
        /**
         * @brief 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.
         *
         * @param in_file       the input archive file.
         * @param regex         the regex used for matching the paths of files inside the archive.
         * @param out_dir       the output directory where extracted files will be put.
         */
        void extractMatchingRegex( const wstring& in_file, const wstring& regex, const wstring& out_dir ) const;
if
        /**
         * @brief Extracts the specified items in the given archive into the choosen directory.
         *
         * @param in_file   the input archive file.
         * @param out_dir   the output directory where extracted files will be put.
         * @param indices   the array of indices of the files in the archive that must be extracted.
         */
        void extractItems( const wstring& in_file,
                           const vector< uint32_t >& indices,
                           const wstring& out_dir = L"" ) const;
        /**
         * @brief Extracts a file from the given archive into the output buffer.
         *
         * @param in_file      the input archive file.
         * @param out_buffer   the output buffer where the content of the archive will be put.
         * @param index        the index of the file to be extracted from in_file.
         */
        void extract( const wstring& in_file, vector< byte_t >& out_buffer, unsigned int index = 0 ) const;
        /**
         * @brief Extracts a file from the given archive into the output stream.
         *
         * @param in_file      the input archive file.
         * @param out_stream   the (binary) stream where the content of the archive will be put.
         * @param index        the index of the file to be extracted from in_file.
         */
        void extract( const wstring& in_file, ostream& out_stream, unsigned int index = 0 ) const;
        /**
         * @brief 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.
         *
         * @param in_file   the input archive file.
         * @param out_map   the output map.
         */
        void extract( const wstring& in_file, map< wstring, vector< byte_t > >& out_map ) const;
        /**
         * @brief Tests the given archive without extracting its content.
         *
         * If the input archive is not valid, a BitException is thrown!
         *
         * @param in_file   the input archive file to be tested.
         */
        void test( const wstring& in_file ) const;
    private:
        void extractMatchingFilter( const wstring& in_file,
                                    const wstring& out_dir,
                                    const function< bool( const wstring& ) >& filter ) const;
};





Add Discussion as Guest

Log in