tar_light for Rust
A simple and lightweight tar archive reader and writer library in Rust.
Features
- 📦 Pack and unpack TAR archives (
.tar) - 🗜️ Support for gzip compression (
.tar.gz,.tgz) - 📋 List files in archives
- 🚀 Simple and intuitive API
- 🔧 Command-line tool included
- ⚡ No external dependencies except
flate2for gzip support
Installation
Add to your Cargo.toml:
[]
= "0.1"
Or use cargo:
Usage
Packing files into a TAR archive
use pack;
// Create plain TAR archive
let files = vec!;
pack;
// Create gzip-compressed TAR archive
pack;
Unpacking files from a TAR archive
use unpack;
// Extract plain TAR archive
unpack;
// Extract gzip-compressed TAR archive
unpack;
Listing files in a TAR archive
use list;
// Works with both .tar and .tar.gz
match list
Advanced usage with low-level API
use ;
use fs;
// Reading TAR archives
let tar_data = read.unwrap;
let entries = read_tar;
for entry in entries
// Creating TAR archives
let mut entries = Vecnew;
let header = new;
let data = b"Hello, World".to_vec;
let header_bytes = header.to_bytes;
entries.push;
let tar_data = write_tar;
write.unwrap;
Command Line Tool
The library includes a command-line tool for basic tar operations:
# Pack files into TAR archive
# Pack files into gzip-compressed TAR archive
# Unpack archive
# Unpack gzip-compressed archive
# List files in archive
Supported Formats
.tar- Plain TAR archives.tar.gz- Gzip-compressed TAR archives.tgz- Gzip-compressed TAR archives (alternative extension)
The format is automatically detected based on the file extension.
License
MIT