开源归档工具库集-libarchive
2022-08-05 21:17:44 阿炯

多格式归档和压缩处理库。

Multi-format archive and compression library.


libarchive项目是一个可移植、高效的C开发库,可以读取和写入各种格式的流式档案,包括了使用libarchive库实现的通用tarcpio和zcat命令行工具,提供了用于读写各类档案格式的单一接口工具集。采用C语言开发并在BSD协议下授权。

其支持许多常见的压缩格式,并提供了许多高级功能,例如加密、数字签名、多卷支持等。其主要优点是它的跨平台支持,可以在各种操作系统上运行,包括 Linux、Windows、macOS 等;还提供了多种语言的绑定,如 Perl、Ruby、Python 等,使得开发人员可以方便地在自己喜欢的编程语言中使用它。


特性

支持多种存档和压缩格式。
强大的自动格式检测,包括存档/压缩组合,如tar.gz。
零拷贝的内部架构实现高性能。
流式体系结构消除了存档大小的所有限制,条目大小的限制取决于特定的格式。
当程序静态链接的方式编译时,细分解代码以最小化体积。
增加测试套件以验证新功能的正确性。
适用于大多数类POSIX的系统(包括FreeBSD、Linux、Solaris等)。
支持Windows,包括Cygwin、MinGW和Visual Studio。

bsdtar和bsdcpio命令行实用程序在功能与性能方面与其他tar和cpio的实现不相伯仲:
可读取多种格式,包括tar、pax、cpio、zip、xar、lha、ar、cab、mtree、rar和ISO镜像;
可建立tar、pax、cpio、zip、xar、ar、ISO、mtree和shar存档格式;
自动处理经gzip、bzip2、lzip、xz、lzma或compress压缩的归档;
独特的格式转换功能。


包含了如下的主要组件:
libarchive:一个用于读写归档流的库;
tar:bsdtar是一个基于libarchive的全功能tar实现;
cpio:bsdcpio是本质上相同功能的不同接口;
cat:bsdcat是zcat、bzcat、xzcat等的简单替换工具;
示例:您可能会发现一些有用的小型示例程序。

支持的格式

目前,库自动检测并读取以下格式:
Old V7 tar archives
POSIX ustar
GNU tar format (including GNU long filenames, long link names, and sparse files)
Solaris 9 extended tar format (including ACLs)
POSIX pax interchange format
POSIX octet-oriented cpio
SVR4 ASCII cpio
Binary cpio (big-endian or little-endian)
PWB binary cpio
ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
ZIPX archives (with support for bzip2, ppmd8, lzma and xz compressed entries)
GNU and BSD 'ar' archives
'mtree' format
7-Zip archives
Microsoft CAB format
LHA and LZH archives
RAR and RAR 5.0 archives (with some limitations due to RAR's proprietary status)
XAR archives

在归档被处理之前,库还会检测并处理以下任何情况:
uuencoded files
files with RPM wrapper
gzip compression
bzip2 compression
compress/LZW compression
lzma, lzip, and xz compression
lz4 compression
lzop compression
zstandard compression

通过调用该库还可以创建以下任何格式的归档:
POSIX ustar
POSIX pax interchange format
"restricted" pax format, which will create ustar archives except for entries that require pax extensions (for long filenames, ACLs, etc).
Old GNU tar format
Old V7 tar format
POSIX octet-oriented cpio
SVR4 "newc" cpio
Binary cpio (little-endian)
PWB binary cpio
shar archives
ZIP archives (with uncompressed or "deflate" compressed entries)
GNU and BSD 'ar' archives
'mtree' format
ISO9660 format
7-Zip archives
XAR archives


创建存档时,可以使用以下任意一项功能或工具来共同处理:
uuencode
gzip compression
bzip2 compression
compress/LZW compression
lzma, lzip, and xz compression
lz4 compression
lzop compression
zstandard compression


最新版本:3.6.1
于2022年4月上旬发布。


官方主页:
https://www.libarchive.org/
https://github.com/libarchive/libarchive