unarc-rs
A Rust library for reading and extracting various archive formats, with a focus on legacy/retro formats from the BBS era, plus modern formats like 7z.
Supported Formats
Archive Formats
| Format | Extensions | Compression | Encryption | Multi-Volume |
|---|---|---|---|---|
| 7z | .7z |
LZMA, LZMA2, etc. | AES-256 ✓ | ✓ |
| ZIP | .zip |
Deflate, legacy methods | ZipCrypto, AES ✓ | ✓ |
| RAR | .rar |
RAR4 & RAR5 | AES ✓ | — |
| LHA/LZH | .lha, .lzh |
Full support | — | — |
| TAR | .tar |
Full support | — | — |
| ACE | .ace |
Stored, LZ77, Blocked | Blowfish ✓ | ✓ |
| ARJ | .arj |
Full support | Garble, GOST40 ✓ | ✓ |
| ARC/PAK | .arc, .pak |
Full support | XOR ✓ | — |
| ZOO | .zoo |
Full support | — | — |
| HA | .ha |
Full support | — | — |
| UC2 | .uc2 |
Full support | — | — |
| SQ/SQ2 | .sq, .sq2, .qqq, ?q? |
Full support | — | — |
| SQZ | .sqz |
Full support | — | — |
| HYP | .hyp |
Full support | — | — |
Single-File Compression
| Format | Extensions | Notes |
|---|---|---|
| Z | .Z |
Full support |
| GZ | .gz |
Gzip (Deflate) |
| BZ2 | .bz2 |
Bzip2 |
| ICE | .ice |
Full support |
| Pack-Ice | .pi9 |
Full support |
Compressed Archives
| Format | Extensions | Notes |
|---|---|---|
| TGZ | .tgz, .tar.gz |
Gzip-compressed TAR |
| TBZ | .tbz, .tbz2, .tar.bz2 |
Bzip2-compressed TAR |
| TAR.Z | .tar.Z |
LZW-compressed TAR |
Note: Single-file formats (
.Z,.gz,.bz2) compress one file only. When a path likefile.tar.gzis opened, the library detects it as a compressed TAR archive, returning all entries from the inner TAR.
Installation
Add to your Cargo.toml:
[]
= "0.6"
Quick Start
Using the Unified API (Recommended)
use ArchiveFormat;
// Open archive directly from path
let mut archive = open_path?;
// Iterate over entries
for entry in archive.entries_iter
Extracting Files
use File;
use ArchiveFormat;
let mut archive = open_path?;
while let Some = archive.next_entry?
Using a Specific Format
use File;
use ArchiveFormat;
let file = open?;
let mut archive = Arj.open?;
for entry in archive.entries_iter
Format Detection
use Path;
use ;
// Check if a file is a supported archive
if is_supported_archive
// Get format from path
if let Some = from_path
API Overview
ArchiveFormat
open_path(path)- Open archive from file path (auto-detects format)open(reader)- Open archive from anyRead + Seekopen_multi_volume_zip(paths, options)- Open multi-volume ZIP archiveopen_multi_volume_7z(paths, options)- Open multi-volume 7z archivefrom_path(path)- Detect format from pathname()/extension()/extensions()- Format metadata
UnifiedArchive
next_entry()- Get next entry (returnsOption<ArchiveEntry>)entries_iter()- Iterator over all entriesread(&entry)- Read entry data intoVec<u8>read_to(&entry, &mut writer)- Stream entry data to writerskip(&entry)- Skip entry without reading
ArchiveEntry
name()/file_name()- Entry name (with/without path)original_size()/compressed_size()- Sizescompression_method()- Compression algorithm usedcompression_ratio()- Compression efficiencymodified_time()- Modification timestampcrc()- Checksumencryption()- Encryption method usedis_encrypted()- Whether the entry is encrypted
Encryption Support
Several formats support encrypted archives:
| Format | Encryption Methods | Notes |
|---|---|---|
| 7z | AES-256 | Strong encryption |
| ZIP | ZipCrypto, AES-128/192/256 | ZipCrypto is weak |
| RAR | AES-128/256 | Legacy RAR encryption is weak |
| ACE | Blowfish | |
| ARJ | Garble, GOST40, GOST-256 | GOST-256 requires ARJCRYPT and is not supported |
| ARC/PAK | XOR (password) | No reliable encryption flag; wrong password typically yields CRC errors |
| UC2 | UltraCrypt (UE2) | Detected but not supported (decrypt with UCRYPT first) |
To decrypt, use ArchiveOptions with a password:
use ;
let mut archive = open_path?;
let options = new.with_password;
while let Some = archive.next_entry?
Format-Specific Notes
7z
Full support via the sevenz-rust2 crate. Supports LZMA, LZMA2, and other 7z compression methods. AES-256 encrypted archives are supported (password required).
Multi-volume support: Split 7z archives (.7z.001, .7z.002, etc.) are supported via open_multi_volume_7z().
ZIP
Full support via the zip crate with legacy compression methods enabled.
Multi-volume support: Split ZIP archives (.zip.001, .z01/.z02/.zip, etc.) are supported via open_multi_volume_zip().
RAR
Full support for RAR4 and RAR5 via the unrar crate (uses native unrar library).
LHA/LZH
Full support via the excellent delharc crate.
ACE
ACE archive support with LZ77+Huffman decompression. Supports both ACE 1.0 (LZ77 mode) and ACE 2.0 (Blocked mode). Blowfish encryption is supported (password required). Multi-volume archives are not supported.
See https://github.com/droe/acefile for format documentation.
ARC
Classic DOS archiver. Full support for all compression methods including Crushed (Method 10) and Distilled (Method 11).
ARC/PAK can be password-decrypted (simple XOR), but the format has no reliable encryption flag in headers.
ARJ
Popular in the BBS scene in the 90s. Supports Garble and GOST40 encryption (password required). GOST-256 (ARJCRYPT) is detected but not supported. Multi-volume archives are not supported.
UC2
UltraCompressor II archive format. Supports decompression with SuperMaster dictionary and custom master entries.
UltraCrypt (UE2) encrypted wrappers are detected but not supported.
ZOO
Classic DOS/Amiga archiver from 1986. Native implementation supporting all compression methods.
HA
Harri Hirvola's archiver (1993). Native implementation with ASC (arithmetic coding) and HSC (static Huffman) support.
SQ/SQ2
CP/M and DOS "squeeze" format. Huffman-based compression used for single files, commonly seen as ?Q? patterns (e.g., .BQK for .BAS).
TAR Variants
TAR archives can be wrapped with compression. The library auto-detects .tar.gz, .tar.bz2, and .tar.Z from the file path and handles decompression transparently.
Background
This library was written for my icy_board BBS project. It focuses on extraction (not creation) of legacy archive formats.
Contributions welcome! Contact me on the icy_board repo or via email if I miss issues/PRs here.
Related projects
- ancient - Decompression of many formats
License
MIT OR Apache-2.0