Skip to content
generated from franklange/template

Pigz-inspired parallel gzip implemtation in modern C++.

License

Notifications You must be signed in to change notification settings

franklange/pigz-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pigz-cpp

C++20 parallel implementation of gzip compression using zlib.

This library's approach is heavily inspired by the original pigz implementation by Mark Adler.

Goals

  • made to be used as a library, not as a standalone command line tool
  • only a fraction of the code size and complexity with a minimal performance hit

Dependencies

  • zlib

Example

#include <pigz-cpp/pigz.hpp>

#include <filesystem>
#include <fstream>
#include <iostream>

auto main() -> int
{
    // compress arbitrary file
    const auto z = pigzcpp::zip("/files/inventory.xlsx");

    // compressed data is in zlib format and
    // can be manually decompressed, for example using zlib-flate
    std::ofstream of{"backup.zlib", std::ios::out | std::ios::trunc | std::ios::binary};
    of.write(reinterpret_cast<const char*>(z.data()), z.size());


    // decompress and write out, should be exact same file
    const auto uz = pigzcpp::unzip(z);

    std::ofstream of{"test/roundtrip.txt", std::ios::out | std::ios::trunc | std::ios::binary};
    of.write(reinterpret_cast<const char*>(uz.data()), uz.size());

    return 0;
}

Build and run example

install zlib
git clone https://github.com/franklange/pigz-cpp.git
cd pigz-cpp
mkdir build
cd build
cmake -DPIGZCPP_EXAMPLES=ON ..
cmake --build . -j
./bin/pigz-cpp-example bin/files/alice.txt

About

Pigz-inspired parallel gzip implemtation in modern C++.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published