cPresser is a lossless file compressor written in C. It tries 4 compression methods and keeps a stage only when it makes the data smaller:
- Delta XOR encoding
- Run-length encoding (RLE)
- Huffman coding
- LZ77
The output header records which stages were used, allowing the decompressor to reverse them automatically.
You need a C compiler and CMake 3.16 or newer.
git clone https://github.com/shahyaranfaz/cPresser.git
cd cPresser
cmake -S . -B build
cmake --build buildThe executable is written to the build directory. With a multi-configuration generator, it may be inside a configuration directory such as build/Release.
Run the executable and choose an action at the prompt:
./build/cPressUse c to compress a file:
Compress (c), Decompress (d), or Exit (x): c
Enter filename: myfile.txt
Success! Output written to 'myfile.txt.cPressed' (1234 bytes, 0.045 seconds)
Use d to restore a .cPressed file:
Compress (c), Decompress (d), or Exit (x): d
Enter filename: myfile.txt.cPressed
Success! Output written to 'myfile.txt.cPressed.original' (5678 bytes, 0.032 seconds)
Enter x to quit.
The test suite checks round trips for single-byte input, RLE length boundaries, repeated and structured text, all byte values, and deterministic random data.
ctest --test-dir build --output-on-failureThe benchmark covers all 12 files in the Silesia compression corpus. It checks the published size of each source file, compresses and decompresses it, then compares the restored file with the source using SHA-256.
python benchmarks/benchmark_silesia.py build/cPressThe recorded run reduced 211,938,580 bytes to 112,385,535 bytes. The compressed output was 53.03% of the original size, a 46.97% reduction. See the full results for per-file ratios, timings, environment, and methodology.
cPresser reads a complete file into memory, and compression stages may allocate additional buffers. The practical file-size limit depends on available memory.