Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A powerful CLI compression tool written in Rust, inspired by 7-Zip but with a modern CLI interface—delivering up to ~100x faster compression and producing archives up to ~6,600x smaller than native zip on highly compressible data.

Notifications You must be signed in to change notification settings

nim444/ferrozip

Repository files navigation

Rust Ubuntu Windows 11 macOS GitHub Copilot GitHub Actions

Unit Tests Binary Build Linux Build MacOS CodeQL



Ferrozip Introduction

A powerful command-line compression tool written in Rust, inspired by 7-Zip but with a modern CLI interface—delivering up to ~100x faster compression and producing archives up to ~6,600x smaller than native zip on highly compressible data.

Ferrozip Benchmark

Features

  • Superior Compression: Achieves significantly higher compression ratios than native zip, especially on highly compressible data (up to 6,600x smaller archives).
  • Fast Performance: Delivers up to 10x faster compression compared to native zip on suitable data types.
  • Efficient Compression: Compress files and directories with customizable compression levels (1-9)
  • Strong Security: Password protect your archives with secure encryption
  • Volume Splitting: Split large archives into smaller volumes for easier sharing and storage
  • Maximum Compression Mode: Optimize for smallest possible file sizes with the --max option
  • Multi-Volume Support: Create and extract multi-part archives seamlessly
  • Archive Management: List, extract, and verify archive contents
  • User-Friendly CLI: Simple, intuitive command interface with clear progress indicators

Ferrozip Demo


1. Requirements
  • Rust: 1.56.0 or newer
  • 7z Command Line Tool: Ferrozip relies on the 7z command line tool for some operations
    • On macOS: brew install p7zip
    • On Ubuntu/Debian: sudo apt-get install p7zip-full
    • On Windows: Install from 7-zip.org and ensure it's in your PATH
2. Installation

From Source

# Clone the repository
git clone https://github.com/nim444/ferrozip.git
cd ferrozip

# Build with cargo
cargo build --release

# The executable will be in target/release/ferrozip
# Optional: Move to a directory in your PATH
cp target/release/ferrozip /usr/local/bin/  # Linux/macOS

Cargo Install : TODO

# Coming soon!
cargo install ferrozip

Homebrew Install : TODO

# Coming soon!
brew install ferrozip

Snapd Install : TODO

# Coming soon!
snap install ferrozip
3. Project Structure
├── .git/
├── .github/
│   └── workflows/
│       ├── build-linux.yml
│       ├── build-mac.yml
│       └── cargo-test.yml
├── src/
│   ├── main.rs                 # Application entry point
│   ├── cli/                    # CLI functionality
│   │   ├── mod.rs             # Module re-exports
│   │   ├── app.rs             # CLI app definition
│   │   └── commands.rs        # CLI commands
│   ├── compress/              # Compression functionality
│   │   ├── mod.rs             # Module re-exports
│   │   ├── core.rs            # Core compression logic
│   │   ├── split.rs           # Archive splitting
│   │   ├── utils.rs           # Compression utilities
│   │   └── tests.rs           # Tests for compression
│   ├── decompress/            # Decompression functionality
│   │   ├── mod.rs             # Module re-exports
│   │   ├── core.rs            # Core decompression logic
│   │   ├── combine.rs         # Archive combining
│   │   ├── list.rs            # Archive listing
│   │   ├── utils.rs           # Decompression utilities
│   │   └── tests.rs           # Tests for decompression
│   └── helpers/               # Helper utilities
│       ├── mod.rs             # Module re-exports
│       ├── size.rs            # Size-related utilities
│       └── text.rs            # Text-related utilities
├── .gitignore
├── Cargo.lock
├── Cargo.toml
└── README.md
4. Usage

Basic Commands

# Compress a directory
ferrozip compress my_folder

# Extract an archive
ferrozip extract archive.7z

# List archive contents
ferrozip list archive.7z
5. Compression Options
# Set compression level (1-9, default is 6)
ferrozip compress data --level 8

# Maximum compression (equivalent to --level 9)
ferrozip compress large_folder --max

# Password protection
ferrozip compress sensitive_data --password "your_password"

# Split into volumes
ferrozip compress huge_folder --split 5g  # 5GB volumes
ferrozip compress media --split 700m      # CD-sized volumes

# Specify custom output filename
ferrozip compress documents --output backup.7z

# Combine multiple options
ferrozip compress important_data --max --split 2g --password "secure_password"
6. Extraction Options
# Extract to specific directory
ferrozip extract archive.7z --output /path/to/extract

# Extract password-protected archive
ferrozip extract secure.7z --password "your_password"

# Extract split archive (just point to the first part)
ferrozip extract large_file.7z.001
7. Size Units

When using the --split option, you can specify sizes with the following units:

  • g for gigabytes (e.g., 5g = 5 gigabytes)
  • m for megabytes (e.g., 500m = 500 megabytes)
  • k for kilobytes (e.g., 1024k = 1 kilobyte)
  • b for bytes (e.g., 1048576b = 1,048,576 bytes)
8. Real-World Examples
# Back up your home folder with maximum compression
ferrozip compress $HOME/Documents --max --output documents_backup.7z

# Create encrypted backups of sensitive information
ferrozip compress financial_records --password "strong_password" --max

# Share large files by splitting them into manageable chunks
ferrozip compress large_dataset --split 1g --output dataset_to_share.7z

# Create DVD-sized backups
ferrozip compress media_collection --split 4.7g

# Quick compression of a project folder
ferrozip compress my_project --level 1 --output quick_backup.7z
9. Troubleshooting

Common Issues

  • "Failed to execute 7z command": Ensure the 7z command-line tool is installed and in your PATH
  • "Archive does not exist": Check that the file path is correct and the archive exists
  • "Invalid password": The password provided doesn't match the one used to encrypt the archive
  • "Invalid size format": When using --split, ensure you're using valid size units (g, m, k, b)
10. Performance Tips
  • Use --level 1 for faster compression with larger file sizes
  • Use --max when storage space is the primary concern
  • For optimal balance, use the default compression level (6)
12. Compression Benchmark

This section presents a real-world compression benchmark comparing Ferrozip (using 7z/LZMA2) and native zip compression on highly compressible dummy database files.

-rw-r--r--@ 1 nk  staff   15K May  7 13:22 dummy_100mb.7z
-rw-r--r--@ 1 nk  staff  100M May  7 13:19 dummy_100mb.db
-rw-r--r--@ 1 nk  staff  298K May  7 13:27 dummy_100mb.zip
-rw-r--r--@ 1 nk  staff  155K May  7 13:29 dummy_1gb.7z
-rw-r--r--@ 1 nk  staff  1.0G May  7 13:20 dummy_1gb.db
-rw-r--r--@ 1 nk  staff  3.0M May  7 13:29 dummy_1gb.zip

📊 Benchmark Summary

File Original Size .7z (Ferrozip) .zip (Native) Compression Ratio
dummy_100mb.db 100 MB 15 KB 298 KB ~6666x smaller (7z)
dummy_1gb.db 1 GB 155 KB 3.0 MB ~6,600x smaller (7z)
11. Running Tests

Ferrozip uses Rust's built-in testing framework. Tests are typically located within the source files in the src/ directory (as modules named tests or functions annotated with #[test]).

To run the test suite, navigate to the project's root directory and execute:

cargo test

This command will compile the project in test mode and run all available tests, providing a summary of the results.

List of Tests
**`src/compress/tests.rs` and `src/compress/split.rs`**
  • test_split_into_multiple_volumes
  • test_split_archive_smaller_than_volume_size
  • test_split_archive_exact_multiple_of_volume_size
  • test_split_empty_archive
  • test_split_volume_size_zero_returns_error
  • test_compress_large_file_and_show_sizes

src/decompress/tests.rs

  • test_combine_multiple_parts
  • test_combine_single_part
  • test_combine_no_parts_found
  • test_combine_missing_middle_part
  • test_combine_parts_in_subdirectory

src/helpers/size.rs and src/helpers/text.rs

  • test_parse_size
  • test_format_size
  • test_truncate_to_width

src/main.rs

  • test_directory_compression_extraction
  • test_single_file_compression_extraction
  • test_password_compression_extraction

Pre-built Binaries

You can download pre-compiled binaries for the most common platforms below. These are development builds from the latest commit. For other systems like Linux, please build from source using the included script.

Platform Architecture Binary Link
Windows x86_64 (64-bit) ferrozip.exe
macOS Intel (x86_64) ferrozip
macOS Apple Silicon (M1/M2) ferrozip
Linux Not provided Build manually using build_multi_platform.sh

Note: Ensure execution permission after download:
chmod +x ferrozip (macOS/Linux)

Acknowledgments

  • Inspired by the 7-Zip project
  • Built with Rust and various open-source libraries
  • Coverage Information - Information about code coverage and testing


License: MIT

About

A powerful CLI compression tool written in Rust, inspired by 7-Zip but with a modern CLI interface—delivering up to ~100x faster compression and producing archives up to ~6,600x smaller than native zip on highly compressible data.

Topics

Resources

Security policy

Stars

Watchers

Forks