ddn.archive.ar

ddn.archive.ar

AR archive reader and writer implementing ddn.api.archive.

Supports the System V / GNU AR format used for Unix .a static libraries and .deb packages. Long filenames are handled via the BSD `//` extended name mechanism.

Module Initializers 1

shared static this()

Types 3

private structArEntry
Fields
string path
ulong dataOffset
ulong size
uint mtime
uint uid
uint gid
uint mode
Fields
private const(ubyte)[] _data
private ReadOptions _opts
private bool _closed
private ArEntry[] _entries
private size_t _iterIndex
private bool _iterating
private ArchiveProgressCallback _progressCallback
private string _longNames
Methods
ArchiveFormat format() @property const
size_t entryCount() @property const
string comment() @property const
bool nextEntry(out EntryInfo info)
bool contains(string path)
EntryInfo getEntry(string path)
void readContent(ref const EntryInfo entry, ContentSink sink)
void extractTo(ref const EntryInfo entry, string destPath)
void extractAll(string destDir)
void close()
bool isClosed() @property const
private void parseArchive()
Constructors
this(const(ubyte)[] data, ReadOptions opts)
Fields
private ContentSink _sink
private WriteOptions _opts
private bool _finished
private bool _closed
private ulong _bytesWritten
private size_t _entriesWritten
private ArchiveProgressCallback _progressCallback
private size_t _longNamesLength
Methods
ArchiveFormat format() @property const
void addDirectory(string path, FilePermissions perms = FilePermissions.init)
void addFile(string path, const(ubyte)[] content, EntryWriteOptions opts = EntryWriteOptions.init)
void addFile(string path, scope const(ubyte)[] delegate() source, ulong size = 0, EntryWriteOptions opts = EntryWriteOptions.init)
void addFileFrom(string archivePath, string filesystemPath, EntryWriteOptions opts = EntryWriteOptions.init)
void addSymlink(string path, string target)
void addHardlink(string path, string target)
void addEntry(ref const EntryInfo info, scope const(ubyte)[] delegate() source)
void removeEntry(string path)
void updateEntry(string path, const(ubyte)[] content, EntryWriteOptions opts = EntryWriteOptions.init)
void setComment(string comment)
void finish()
void close()
bool isFinished() @property const
bool isClosed() @property const
ulong bytesWritten() @property const
size_t entriesWritten() @property const
private void writeGlobalHeader()
private void writeEntry(string name, const(ubyte)[] content, FilePermissions perms)
private void emit(const(ubyte)[] data)
Constructors

Functions 7

private fnulong parseArField(const(ubyte) * field, size_t length) pure nothrowParse an ASCII decimal field from an AR header, stripping trailing spaces.
private fnvoid writeArField(ubyte * field, size_t length, ulong value) @trusted nothrowWrite an ASCII decimal value into an AR header field, space-padded.
private fnvoid writeArOctalField(ubyte * field, size_t length, ulong value) @trusted nothrowWrite an ASCII octal value into an AR header field, space-padded.
private fnstring readArString(const(ubyte) * field, size_t length) pure nothrowRead a NUL-terminated string from an AR header field.
fnArchiveReader makeArReader(const(ubyte)[] data, ReadOptions opts)
fnArchiveFormat detectArFormat(const(ubyte)[] header)

Variables 3

private enumvarAR_MAGIC = "!<arch>\x0A"
private enumvarAR_FMAG = "\x60\x0A"
private enumvarAR_HEADER_SIZE = 60