API of totebag crate
:speaking_head: Overview
This is the README for the totebag crate, which provides the API of the totebag tool for extracting/archiving files and directories in multiple formats.
The totebag crate provides a unified API for handling various archive formats, making it easy for developers to integrate archiving and extraction functionality into their Rust applications.
It abstracts the differences between various archive formats, providing a consistent interface for working with archives.
Supported archive formats
- Ar
- Cab
- Cpio
- Tar
- Tar+Gzip
- Tar+Bzip2
- Tar+Xz
- Tar+Zstd
- Zip
- 7z
- Lha, Lzh (extraction only)
- Rar (extraction only)
:walking: How to use
:green_heart: Archiving files and directories
use PathBuf;
let config = builder
.dest // destination file.
.rebase_dir // rebased directory in the archive file.
.overwrite // set overwrite flag of the destination file.
.build;
let targets: = vec!.iter // files to be archived.
.map.;
match archive
:yellow_heart: Extracting the archive file
use PathBuf;
let config = builder
.dest // set the destination directory.
.build;
match extract
Compression level
| Level | |
|---|---|
| Ar | N/A |
| Cab | 0: None, otherwise: MsZIP; see CompressionType. |
| Cpio | 0-3: Odc, 4-6: Newc, 7: Crc, 8: Bin(LittleEndian), 9: Bin(BigEndian); see kpea::Format. |
| Gzip | See Compression. |
| Bzip2 | See Compression. |
| Xz | See XzEncoder. |
| Zstd | Map 1-22 to 0-9 See Encoder. |
| Zip | 0: No compression, 1-3: Deflate (10, 24, 264), 4-6: Bzip2 (1, 6, 9), 7-9: Zstd (-7, 3, 22); see FileOptions. |
| 7z | 0-4: LZMA, 5-9: LZMA64 (SevenZMethod) |
:blue_heart: List entries in an archive file
The list function returns a string-formatted list of entries in the archive file.
use PathBuf;
let file = from;
let config = new;
match list
The entries function returns a vector of Entry objects that are reflected in the archive file.
use PathBuf;
let file = from;
match entries