Function compressFile

Summary

#include <include/bitcompressor.hpp>

(1) void compressFile(const wstring &in_file, const wstring &out_archive) const

(2) void compressFile(const wstring &in_file, vector< byte_t > &out_buffer) const

Function overload

Synopsis

#include <include/bitcompressor.hpp>

void compressFile(const wstring &in_file, const wstring &out_archive) const

Description

Compresses a single file.

Parameters

in_file - the path (relative or absolute) to the input file.

out_archive - the path (relative or absolute) to the output archive file.

Mentioned in

Source

Lines 52-60 in src/bitcompressor.cpp. Line 94 in include/bitcompressor.hpp.

void BitCompressor::compressFile( const wstring& in_file, const wstring& out_file ) const {
    FSItem item( in_file );
    if ( item.isDir() ) {
        throw BitException( "Wrong argument: input path points to a directory, not a file!", E_INVALIDARG );
    }
    vector< FSItem > fs_items;
    fs_items.push_back( item );
    compressOut( fs_items, out_file );
}

Synopsis

#include <include/bitcompressor.hpp>

void compressFile(const wstring &in_file, vector< byte_t > &out_buffer) const

Description

Compresses the input file to the output buffer.

Compression from file system to memory buffer

Note
If the format of the output doesn't support in memory compression, a BitException is thrown.
Parameters

in_file - the file to be compressed.

out_buffer - the buffer going to contain the output archive.

from filesystem to memory buffer

Mentioned in

Source

Lines 85-96 in src/bitcompressor.cpp. Line 139 in include/bitcompressor.hpp.

void BitCompressor::compressFile( const wstring& in_file, vector< byte_t >& out_buffer ) const {
    FSItem item( in_file );
    if ( item.isDir() ) {
        throw BitException( "Cannot compress a directory into a memory buffer!", E_INVALIDARG );
    }

    vector< FSItem > fs_items;
    fs_items.push_back( item );

    CMyComPtr< UpdateCallback > update_callback = new FileUpdateCallback( *this, fs_items );
    BitArchiveCreator::compressToBuffer( out_buffer, update_callback );
}





Add Discussion as Guest

Log in