예제 #1
0
void ZipArchive::reset() {
    // Close and free the miniz archive (if null, this is a no-op).
    mz_zip_reader_end(&minizData);
    mz_zip_zero_struct(&minizData);
    // Empty the buffer and entry list.
    buffer.clear();
    entryList.clear();
}
예제 #2
0
파일: lminiz.c 프로젝트: starwing/luabuild
static int Lzip_write_file(lua_State *L) {
    const char *filename = luaL_checkstring(L, 1);
    size_t size_to_reserve_at_beginning = (size_t)luaL_optinteger(L, 2, 0);
    mz_zip_archive* za = (mz_zip_archive*)lua_newuserdata(L, sizeof(mz_zip_archive));
    mz_zip_zero_struct(za);
    if (!mz_zip_writer_init_file(za, filename, size_to_reserve_at_beginning))
        return lmz_zip_pusherror(L, za, filename);
    luaL_setmetatable(L, LMZ_ZIP_WRITER);
    return 1;
}
예제 #3
0
파일: lminiz.c 프로젝트: starwing/luabuild
static int Lzip_read_file(lua_State *L) {
    const char *filename = luaL_checkstring(L, 1);
    mz_uint32 flags = (mz_uint32)luaL_optinteger(L, 2, 0);
    mz_zip_archive *za = lua_newuserdata(L, sizeof(mz_zip_archive));
    mz_zip_zero_struct(za);
    if (!mz_zip_reader_init_file(za, filename, flags))
        return lmz_zip_pusherror(L, za, filename);
    luaL_setmetatable(L, LMZ_ZIP_READER);
    return 1;
}
예제 #4
0
파일: lminiz.c 프로젝트: starwing/luabuild
static int Lzip_write_string(lua_State *L) {
    size_t size_to_reserve_at_beginning = (size_t)luaL_optinteger(L, 1, 0);
    size_t initial_allocation_size = (size_t)luaL_optinteger(L, 2, LUAL_BUFFERSIZE);
    mz_zip_archive* za = (mz_zip_archive*)lua_newuserdata(L, sizeof(mz_zip_archive));
    mz_zip_zero_struct(za);
    if (!mz_zip_writer_init_heap(za,
                size_to_reserve_at_beginning, initial_allocation_size))
        return lmz_zip_pusherror(L, za, NULL);
    luaL_setmetatable(L, LMZ_ZIP_WRITER);
    return 1;
}
예제 #5
0
파일: lminiz.c 프로젝트: starwing/luabuild
static int Lzip_read_string(lua_State *L) {
    size_t len;
    const char *s = luaL_checklstring(L, 1, &len);
    mz_uint32 flags = (mz_uint32)luaL_optinteger(L, 2, 0);
    mz_zip_archive *za = lua_newuserdata(L, sizeof(mz_zip_archive));
    mz_zip_zero_struct(za);
    if (!mz_zip_reader_init_mem(za, s, len, flags))
        return lmz_zip_pusherror(L, za, NULL);
    luaL_setmetatable(L, LMZ_ZIP_READER);
    lua_pushvalue(L, 1);
    lua_rawsetp(L, LUA_REGISTRYINDEX, za);
    return 1;
}
예제 #6
0
ZipArchive::ZipArchive() {
    mz_zip_zero_struct(&minizData);
}