Ejemplo n.º 1
0
void ZipWriter::close()
{
    if (_out) {
        mz_zip_writer_finalize_archive(&_archive);
        mz_zip_writer_end(&_archive);
        _out.reset();
    }
}
Ejemplo n.º 2
0
    void ArchiveWriter::Close()
    {
        mz_zip_archive* zip = (mz_zip_archive*)zip_obj_;
        mz_zip_writer_finalize_archive(zip);
        mz_zip_writer_end(zip);
        delete zip;

        zip_obj_ = NULL;
    }
Ejemplo n.º 3
0
static int Lwriter_finalize(lua_State *L) {
    mz_zip_archive *za = (mz_zip_archive*)luaL_checkudata(L, 1, LMZ_ZIP_WRITER);
    if (mz_zip_get_type(za) == MZ_ZIP_TYPE_HEAP) {
        size_t len = 0;
        void* s = NULL;
        mz_bool result = mz_zip_writer_finalize_heap_archive(za, &s, &len);
        lua_pushlstring(L, s, len);
        free(s);
        return result ? 1 : lmz_zip_pusherror(L, za, NULL);
    } else if (!mz_zip_writer_finalize_archive(za))
        return lmz_zip_pusherror(L, za, NULL);
    return_self(L);
}
Ejemplo n.º 4
0
void zip_file::save(std::vector<unsigned char> &bytes)
{
    if(archive_->m_zip_mode == MZ_ZIP_MODE_WRITING)
    {
        mz_zip_writer_finalize_archive(archive_.get());
    }
    
    if(archive_->m_zip_mode == MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)
    {
        mz_zip_writer_end(archive_.get());
    }
    
    if(archive_->m_zip_mode == MZ_ZIP_MODE_INVALID)
    {
        start_read();
    }
    
    append_comment();
    bytes.assign(buffer_.begin(), buffer_.end());
}
Ejemplo n.º 5
0
void zip_file::save(std::ostream &stream)
{
    if(archive_->m_zip_mode == MZ_ZIP_MODE_WRITING)
    {
        mz_zip_writer_finalize_archive(archive_.get());
    }
    
    if(archive_->m_zip_mode == MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)
    {
        mz_zip_writer_end(archive_.get());
    }
    
    if(archive_->m_zip_mode == MZ_ZIP_MODE_INVALID)
    {
        start_read();
    }
    
    append_comment();
    stream.write(buffer_.data(), buffer_.size());
}