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
| Format | Extensions | Compression Support |
|---|---|---|
| 7z | .7z |
Full support via sevenz-rust2 |
| ZIP | .zip |
Full support via zip crate (including legacy methods) |
| RAR | .rar |
Full support via unrar (RAR4 & RAR5) |
| LHA/LZH | .lha, .lzh |
Full support via delharc |
| ARJ | .arj |
Store, Method 1-4 |
| ARC | .arc |
Unpacked, Packed, Squeezed, Crunched, Squashed |
| ZOO | .zoo |
Methods 0, 1, 2 |
| UC2 | .uc2 |
Full LZ77+Huffman decompression |
| SQ/SQ2 | .sq, .sq2, .qqq, ?q? |
Squeezed |
| SQZ | .sqz |
Store only |
| HYP | .hyp |
Store only |
| Z | .Z |
LZW (Unix compress) |
Installation
Add to your Cargo.toml:
[]
= "0.5"
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 + Seekfrom_path(path)/from_extension(ext)- Detect formatname()/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()- Checksum
Format-Specific Notes
7z
Full support via the sevenz-rust2 crate. Supports LZMA, LZMA2, and other 7z compression methods.
ZIP
Full support via the zip crate with legacy compression methods enabled.
RAR
Full support for RAR4 and RAR5 via the unrar crate (uses native unrar library).
LHA/LZH
Full support via the excellent delharc crate.
ARC
Classic DOS archiver. Crushed & Distilled methods are not supported.
ARJ
Popular in the BBS scene in the 90s. Multi-volume and encrypted archives are not supported.
UC2
UltraCompressor II archive format. Supports decompression with SuperMaster dictionary and custom master entries.
Out of Scope
Not on the todo list:
- TAR - Use tar
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.
License
MIT OR Apache-2.0