Function compressToFile

Synopsis

#include <include/bitarchivecreator.hpp>

void compressToFile(const wstring &out_file, UpdateCallback *update_callback) const

Description

No description yet.

Source

Lines 262-280 in src/bitarchivecreator.cpp. Line 198 in include/bitarchivecreator.hpp.

void BitArchiveCreator::compressToFile( const wstring& out_file, UpdateCallback* update_callback ) const {
    unique_ptr< BitInputArchive > old_arc = nullptr;
    CMyComPtr< IOutArchive > new_arc = initOutArchive();
    CMyComPtr< IOutStream > out_stream = initOutFileStream( out_file, new_arc, old_arc );
    update_callback->setOldArc( old_arc.get() );
    compressOut( new_arc, out_stream, update_callback );
    if ( old_arc ) {
        old_arc->close();
        auto out_file_stream = dynamic_cast< COutFileStream* >( *&out_stream ); //cast should not fail, but anyway...
        if ( out_file_stream ) {
            out_file_stream->Close();
        }
        //remove old file and rename tmp file (move file with overwriting)
        bool renamed = fsutil::renameFile( out_file + L".tmp", out_file );
        if ( !renamed ) {
            throw BitException( L"Cannot rename temp archive file to  '" + out_file + L"'", GetLastError() );
        }
    }
}





Add Discussion as Guest

Log in