It compress a file into a seekable zstd splitting the file into multiple frames.
If the file is a tar archive it compress each file in the archive into an independent frame, hence the name: tar 2 seekable zstd.
It operates in two modes. Tar archive mode and raw mode.
By default it runs in tar archive mode for files ending with .tar, unless -r is specified.
For all other files it runs in raw mode.
In tar archive mode it compress the archive keeping each file in a different frame, unless -s or -S is used.
This allows fast seeking and extraction of a single file without decompressing the whole archive.
When -s SIZE is used in tar mode, if the size of the file being compressed into a block is less than SIZE then another one will be added in the same block, and so on until the sum of the sizes of all files packed together is at least SIZE. A file will be never spltted as SIZE is just a minimum value.
When -s SIZE is used in raw mode then it defines exactly the input block size and bigger inputs will be split in blocks of this size accordingly. If there isn't enough input data the last block will be smaller.
When -S SIZE is used, files bigger than SIZE will be splitted in blocks of SIZE length. It is available only in tar mode and ignored in raw mode.
The compressed archive can be decompressed with any Zstandard tool, including zstd.
To take advantage of seeking see the following projects:
- C/C++ library: libzstd-seek - https://github.com/martinellimarco/libzstd-seek
- Python library: indexed_zstd - https://github.com/martinellimarco/indexed_zstd
- FUSE mount: ratarmount - https://github.com/mxmlnkn/ratarmount
Source code available at https://github.com/martinellimarco/t2sz