A minimal command-line file compressor / decompressor written in C using Raylib’s CompressData() and DecompressData() utilities.
The program reads a file into memory, compresses or decompresses the raw bytes, and writes the result to a new file.
This project focuses on learning low-level file I/O, memory management, and command-line argument handling in C.
Tutorial: Video Tutorial Available (by Daniel Hirsch)
- Compress files into
.compressedformat - Decompress files using the
-dflag - Simple CLI interface
- Works on raw binary data
- Uses Raylib’s built-in compression utilities
- Reads command-line arguments to determine compression or decompression mode
- Opens the input file using
fopen() - Determines file size using
fseek()andftell() - Loads the entire file into memory using
malloc() - Uses Raylib’s
CompressData()orDecompressData() - Writes processed bytes to a new output file using
fputc()
Make sure Raylib is installed.
Compile using:
gcc compressor.c -o compress $(pkg-config --cflags --libs raylib)
Compress a file:
./compress file.txt
This creates:
file.txt.compressed
Decompress a file:
./compress -d file.txt.compressed
This creates:
file.txt.compressed.decompressed
-
The entire file is loaded into memory before compression
-
Output files are generated by appending a suffix to the original filename