Code Monkey home page Code Monkey logo

zpack's Introduction

ZPack

build Language grade: C/C++

ZPack is a simple, general-purpose archive file format with lossless data compression (similar to zip, rar, etc.). It is designed with performance in mind and uses fast compression algorithms such as zstd and lz4.

Documentation

The specifications for the ZPack file format can be found here

The API documentation can be generated using Doxygen. An online copy of it can be found here

Installing

Prebuilt Windows and Linux binaries are available on the Releases page.

Compiling

The CMake lists in the root directory can be used to build both the library and the command line utility.

A few options are available when configuring with CMake. Here are some common options:

  • ZPACK_BUILD_PROGRAMS: Build the ZPack command line utility. Default: ON
  • ZPACK_BUILD_TESTS: Build the ZPack unit tests. Default: OFF
  • ZPACK_DISABLE_ZSTD: Disable zstd support. Default: OFF
  • ZPACK_DISABLE_LZ4: Disable LZ4 support. Default: OFF

More options can be found in CMakeLists.txt

To use the library in your CMake project:

set(ZPACK_BUILD_PROGRAMS OFF) # optional
add_subdirectory(path/to/zpack)

target_include_directories(target PRIVATE path/to/zpack/lib)
target_link_libraries(target PRIVATE zpack)

License

ZPack is licensed under the zlib License

zpack's People

Contributors

leadrdrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zpack's Issues

Version 2.0 Roadmap

This issue is for tracking the development progress of version 2.0 which is being done in the next branch. Discussion and suggestions are welcomed.

Progress

  • C Rewrite
  • LZ4 (frame format) support
  • Streaming API
  • CLI rewrite
  • Documentation rewrite
  • Finalize archive file format (version 1)

After v2.0 has been released, 1.0 versions will be considered to be completely obsolete. v2.0 will feature no backwards compatibility with v1.0 (and with archive format version 0)

Why?

  • Version 1.0 was written in a time when I didn't know much about actually writing good code in C/C++.
  • The current C++ API is absolutely ridiculous to use and is specifically engineered for a very specific use case.
    Example: It only supports the use of C++ streams for both reading and writing, and consequently, archives could only be read from a file.
  • Bad file format design which leads to extensive usage of heap memory, which needed to be resized frequently while reading, due to the fact that sizing information provided in the file was insufficient.
  • I want it to be usable in both C and C++ projects (and steer away from C++ if possible).
  • I want it to be less pretentious; I claimed zstd to be the best compression algorithm around and refused to look at any other ones. v2.0 will (hopefully) bring more compression methods to the table, with each of them having a specific advantage for something else (with speed still being the main focus).

read file written by `zpack_init_writer_heap`

when i pass

            if (out_buffer != nullptr && out_size != nullptr) {
                *out_size = sizeof(zpack_u8) * writer.buffer_capacity;
                *out_buffer = (zpack_u8*)malloc(*out_size);
                if (*out_buffer == nullptr) {
                    error_msg_string = "ZPack: Failed to allocate buffer";
                    error_msg = error_msg_string.c_str();
                    return;
                }
                memcpy(*out_buffer, writer.buffer, *out_size);
            }
            int ret;
            if ((ret = zpack_init_reader_memory_shared(&reader, buffer, size))) {
                error_msg_string = "ZPack: Failed to open memory for reading";
                error_msg_string += ", Error: ";
                error_msg_string += zpack_error_to_string(ret);
                error_msg = error_msg_string.c_str();
                return;
            }

i get

archive buffer: 0x7f1d9db49c50
archive size: 2048
ZPack: Failed to open memory for reading, Error: ZPACK_ERROR_SIGNATURE_INVALID

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.