Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file_compressor

A fast command-line file compressor and decompressor written in C, powered by raylib's built-in CompressData / DecompressData functions (DEFLATE via miniz).

demo

$ ./compress myfile.txt
file size: 2048
data compressed
→ myfile.txt.zip

$ ./compress -d myfile.txt.zip
file size: 512
data decompressed
→ myfile.txt.zip.zip

features

  • lossless DEFLATE compression via raylib/miniz
  • single-file C source — easy to read and modify
  • compress any binary or text file
  • decompress with a single -d flag
  • no external dependencies beyond raylib

build

requirements: gcc, raylib installed on your system

# clone
git clone https://github.com/YOUR_USERNAME/file_compressor.git
cd file_compressor

# compile
gcc main.c -o compress -lraylib -lm

# or with make
make

installing raylib

# ubuntu / debian
sudo apt install libraylib-dev

# arch
sudo pacman -S raylib

# macOS
brew install raylib

# windows (via vcpkg)
vcpkg install raylib

usage

# compress a file  →  produces <filename>.zip
./compress <file>

# decompress a file
./compress -d <file>

examples

./compress photo.png          # → photo.png.zip
./compress archive.tar        # → archive.tar.zip
./compress -d photo.png.zip   # → photo.png.zip.zip

note: the output always appends .zip to the input filename. when decompressing, make sure to pass the .zip file as the argument.

how it works

  1. opens the input file in binary mode and reads it fully into memory
  2. calls raylib's CompressData (compress) or DecompressData (decompress)
  3. writes the result to <input_filename>.zip
  4. frees memory with raylib's MemFree

raylib uses miniz under the hood — a single-file DEFLATE implementation compatible with zlib and the ZIP format.

project structure

file_compressor/
├── main.c          ← all source code
├── Makefile        ← build rules
├── .gitignore      ← ignores binary output
└── README.md

known limitations

  • output filename is always <input>.zip — no custom output path yet
  • entire file is loaded into memory before compression (not streaming)
  • no compression level control

license

MIT — see LICENSE

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages