Function extractItems

Synopsis

#include <include/bitextractor.hpp>

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

Description

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

Parameters

in_file - the input archive file.

out_dir - the output directory where extracted files will be put.

indices - the array of indices of the files in the archive that must be extracted.

Source

Lines 97-114 in src/bitextractor.cpp. Line 91 in include/bitextractor.hpp.

void BitExtractor::extractItems( const wstring& in_file,
                                 const vector< uint32_t >& indices,
                                 const wstring& out_dir ) const {
    if ( indices.empty() ) {
        throw BitException( "Empty indices vector", E_INVALIDARG );
    }

    BitInputArchive in_archive( *this, in_file );
    uint32_t n_items = in_archive.itemsCount();
    const auto find_res = std::find_if( indices.cbegin(), indices.cend(), [ &n_items ]( uint32_t index ) -> bool {
        return index >= n_items;
    });
    if ( find_res != indices.cend() ) {
        throw BitException( L"Index " + std::to_wstring( *find_res ) + L" is not valid", E_INVALIDARG );
    }

    extractToFileSystem( in_archive, in_file, out_dir, indices );
}





Add Discussion as Guest

Log in