ddn.archive.cpio
ddn.archive.cpio
CPIO archive reader and writer implementing ddn.api.archive.
Supports the SVR4 newc (new ASCII) CPIO format, which is the most widely used variant. The newc format uses 110-byte headers with 8-character hexadecimal ASCII fields.
Copyright
BSD-3-Clause
var CPIO_CRC_MAGIC CPIO_HEADER_SIZE CPIO_NEWC_MAGIC CPIO_TRAILER S_IFBLK S_IFCHR S_IFDIR S_IFIFO S_IFLNK S_IFMT S_IFREG S_IFSOCK
struct CpioEntry
Module Initializers 1
shared static this
()Types 3
Fields
string pathulong dataOffsetulong sizeuint modeuint mtimeuint uiduint giduint devMajoruint devMinoruint rdevMajoruint rdevMinorclassCpioReader : ArchiveReader
Fields
private const(ubyte)[] _dataprivate ReadOptions _optsprivate bool _closedprivate CpioEntry[] _entriesprivate size_t _iterIndexprivate bool _iteratingprivate ArchiveProgressCallback _progressCallbackMethods
void setProgressCallback(ArchiveProgressCallback callback)bool contains(string path)void readContent(ref const EntryInfo entry, ContentSink sink)void extractAll(string destDir)void close()private
void parseArchive()Constructors
this(const(ubyte)[] data, ReadOptions opts)classCpioWriter : ArchiveWriter
Fields
private ContentSink _sinkprivate WriteOptions _optsprivate bool _finishedprivate bool _closedprivate ulong _bytesWrittenprivate size_t _entriesWrittenprivate ArchiveProgressCallback _progressCallbackprivate ulong _nextInoMethods
void setOutputSink(ContentSink sink)void setProgressCallback(ArchiveProgressCallback callback)void addDirectory(string path,
FilePermissions perms = FilePermissions.fromOctal(octal!"755"))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 removeEntry(string path)void updateEntry(string path, const(ubyte)[] content,
EntryWriteOptions opts = EntryWriteOptions.init)void setComment(string comment)void finish()void close()private
void writeEntry(string name, const(ubyte)[] data, uint mode, ulong nlink)private
void writeTrailer()private
void emit(const(ubyte)[] data)Constructors
this(ContentSink sink, WriteOptions opts)Functions 8
private fn
ulong parseCpioHexField(const(ubyte) * field) pure nothrowParse an 8-character hex ASCII field from a CPIO newc header.private fn
void writeCpioHexField(ubyte * field, ulong value) @trusted nothrowWrite an 8-character hex ASCII field into a CPIO newc header.private fn
size_t align4(size_t offset) pure nothrow @nogcAlign an offset up to the next 4-byte boundary.private fn
EntryType modeToEntryType(uint mode) pure nothrow @nogcDetermine EntryType from POSIX mode bits.private fn
uint entryTypeToMode(EntryType type) pure nothrow @nogcConvert EntryType to POSIX mode bits (upper portion only).fn
ArchiveReader makeCpioReader(const(ubyte)[] data, ReadOptions opts)fn
ArchiveWriter makeCpioWriter(ContentSink sink, WriteOptions opts)fn
ArchiveFormat detectCpioFormat(const(ubyte)[] header)Variables 12
private enumvar
CPIO_NEWC_MAGIC = "070701"private enumvar
CPIO_CRC_MAGIC = "070702"private enumvar
CPIO_TRAILER = "TRAILER!!!"private enumvar
CPIO_HEADER_SIZE = 110private enumvar
S_IFMT = octal!"170000"private enumvar
S_IFREG = octal!"100000"private enumvar
S_IFDIR = octal!"040000"private enumvar
S_IFLNK = octal!"120000"private enumvar
S_IFSOCK = octal!"140000"private enumvar
S_IFIFO = octal!"010000"private enumvar
S_IFCHR = octal!"020000"private enumvar
S_IFBLK = octal!"060000"