The OpenD Programming Language

arsd.archive

Provides LZMA (aka .xz), gzip (.gz) and .tar file read-only support. Combine to read .tar.xz and .tar.gz files, or use in conjunction with other libraries to read other kinds of files.

Also has a custom archive called arcz read and write support. It is designed to efficiently pack and randomly access large numbers of similar files. Unlike .zip files, it will do cross-file compression (meaning it can significantly shrink archives with several small but similar files), and unlike tar.gz files, it supports random access without decompressing the whole archive to get an individual file. It is designed for large numbers of small, similar files.

Members

Classes

ArzCreator
class ArzCreator

this class can be used to create archive file.

Enums

SEEK_SET (from core.stdc.stdio)
anonymousenum SEEK_SET via public import core.stdc.stdio : SEEK_SET, SEEK_CUR, SEEK_END;
TarFileType
enum TarFileType

There's other types but this is all I care about. You can still detect the char by ((cast(char) type) + '0')

Functions

decompressGzip
void decompressGzip(void delegate(in ubyte[] chunk) chunkReceiver, ubyte[] delegate(ubyte[] buffer) bufferFiller, ubyte[] chunkBuffer, ubyte[] inputBuffer, bool allowPartialChunks)

decompressLzma lzma (.xz file) decoder/decompressor that works by passed functions. Can be used as a higher-level alternative to XzDecoder. decompressGzip is gzip (.gz file) decoder/decompresser) that works by passed functions. Can be used as an alternative to std.zip, while using the same underlying zlib library.

decompressLzma
void decompressLzma(void delegate(in ubyte[] chunk) chunkReceiver, ubyte[] delegate(ubyte[] buffer) bufferFiller, ubyte[] chunkBuffer, ubyte[] inputBuffer, bool allowPartialChunks)

decompressLzma lzma (.xz file) decoder/decompressor that works by passed functions. Can be used as a higher-level alternative to XzDecoder. decompressGzip is gzip (.gz file) decoder/decompresser) that works by passed functions. Can be used as an alternative to std.zip, while using the same underlying zlib library.

processTar
bool processTar(TarFileHeader* header, long* bytesRemainingOnCurrentFile, const(ubyte)[] dataBuffer, void delegate(TarFileHeader* header, bool isNewFile, bool fileFinished, const(ubyte)[] data) handleData)

Low level tar file processor. You must pass it a TarFileHeader buffer as well as a size_t for context. Both must be initialized to all zeroes on first call, then not modified in between calls.

Imports

SEEK_CUR (from core.stdc.stdio)
public import core.stdc.stdio : SEEK_SET, SEEK_CUR, SEEK_END;
SEEK_END (from core.stdc.stdio)
public import core.stdc.stdio : SEEK_SET, SEEK_CUR, SEEK_END;

Structs

AZFile
struct AZFile

Opened file.

ArzArchive
struct ArzArchive

ARZ archive accessor. Use this to open ARZ archives, and open packed files from ARZ archives.

TarFileHeader
struct TarFileHeader

A header of a file in the archive. This represents the binary format of the header block.

XzDecoder
struct XzDecoder

A simple .xz file decoder.

Meta

History

tar code (and arsd module formed) originally written December 2019 to support my d_android library downloader. It was added to dub in March 2020 (dub v7.0).

The LZMA code is a D port of Igor Pavlov's LzmaDec.h, written in 2017 with contributions by Lasse Collin. It was ported to D by ketmar some time after that and included in the original version of arsd.archive in the first December 2019 release.

The arcz code was written by ketmar in 2016 and added to arsd.archive in March 2020.

A number of improvements were made with the help of Steven Schveighoffer on March 22, 2023.

arsd.archive was changed to require arsd.core on March 23, 2023 (dub v11.0). Previously, it was a standalone module. It uses arsd.core's exception helpers only at this time and you could turn them back into plain (though uninformative) D base Exception instances to remove the dependency if you wanted to keep the file independent.