This is a Huffman compression and decompression tool implemented in Ocen, a programming language created by Mustafa.
This program implements the Huffman coding algorithm for lossless data compression. It can both compress and decompress files using Huffman coding.
- File compression using Huffman coding
- File decompression of Huffman-coded files
- Command-line interface for easy usage
- Supports input from files or standard input
- Can output to files or standard output
./huffman <-c|-d> -i <input_path> -o <output_path>
-c
or--compress
: Compress the input file-d
or--decompress
: Decompress the input file-i <path>
or--input <path>
: Specify the input file path (default: /dev/stdin)-o <path>
or--output <path>
: Specify the output file path (default: /dev/stdout)-h
or--help
: Display help information
Compress a file:
./huffman -c -i input.txt -o compressed.bin
Decompress a file:
./huffman -d -i compressed.bin -o decompressed.txt
The compressor uses the following key components:
- A
Node
struct to represent elements in the Huffman tree - A priority queue (implemented as a min-heap) to build the Huffman tree
- Bit-level I/O operations for efficient compression and decompression
- Tree encoding and decoding for storing the Huffman tree structure
To build the project, you need to have the Ocen compiler installed. Once you have it, you can compile the project using:
ocen compressor.oc -o huffman
Check out Ocen