ddn.archive.zip

ddn.archive.zip

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

Module Initializers 1

shared static this()

Types 4

aliasByteSource = size_t delegate(ubyte[] buffer)

Delegate type for streaming byte source.

Called by ZipStreamReader to request more data from the underlying non-seekable source. The delegate should fill the provided buffer with available bytes.

Parameters

bufferThe buffer to fill with data.

Returns

The number of bytes actually read, or 0 on EOF.
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(const EntryInfo entry, ContentSink sink)
void extractTo(ref const EntryInfo entry, string destPath)
void extractAll(string destDir)
void close()
bool isClosed() @property const
Constructors
this(const(ubyte)[] data, ReadOptions opts)
Nested Templates
Zip64Eocd

True streaming ZIP reader that reads entries incrementally from a non-seekable source.

Unlike ZipReader which loads the entire archive and parses the central directory, ZipStreamReader reads local file headers sequentially, allowing processing of archives from pipes, sockets, or other non-seekable sources without buffering the entire archive in memory.

Limitations compared to ZipReader:

  • No random access (getEntry() is not supported)
  • entryCount() returns 0 (unknown until fully read)
  • contains() requires sequential scan
  • Cannot seek backwards to re-read entries

The reader handles both regular ZIP entries and entries with data descriptors (general purpose bit flag 3), as well as ZIP64 extended information.

Methods
ArchiveFormat format() @property constReturns the archive format.
ArchiveCapabilities capabilities() @property constReturns the provider capabilities for streaming mode.
void setProgressCallback(ArchiveProgressCallback callback)Set progress callback for operation monitoring.
size_t entryCount() @property constGet total number of entries.
string comment() @property constGet archive-level comment.
bool nextEntry(out EntryInfo info)Advance to the next entry in the archive.
bool contains(string path)Check if archive contains an entry at path.
EntryInfo getEntry(string path)Get entry info by path.
void readContent(const EntryInfo entry, ContentSink sink)Read entry content, calling sink with chunks of decompressed data.
void extractTo(ref const EntryInfo entry, string destPath)Extract entry to filesystem path.
void extractAll(string destDir)Extract all entries to a directory.
void close()Close the reader and release resources.
bool isClosed() @property constReturns true if reader has been closed.
Constructors
this(ByteSource source, ReadOptions opts)Construct a streaming ZIP reader.
Nested Templates
StreamEntryState
Methods
ArchiveFormat format() @property const
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 addEntry(ref const EntryInfo info, scope const(ubyte)[] delegate() source)
void setComment(string comment)
void removeEntry(string path)
void updateEntry(string path, const(ubyte)[] content, EntryWriteOptions opts = EntryWriteOptions.init)
void finish()
void close()
bool isFinished() @property const
bool isClosed() @property const
ulong bytesWritten() @property const
size_t entriesWritten() @property const
Constructors
Destructors

Functions 4

fnArchiveReader makeZipReader(const(ubyte)[] data, ReadOptions opts)Create a ZipReader for reading from an in-memory buffer.
fnArchiveReader makeZipStreamReader(ByteSource source, ReadOptions opts)Create a ZipStreamReader for reading from a streaming byte source.
fnArchiveWriter makeZipWriter(ContentSink sink, WriteOptions opts)Create a ZipWriter for writing to an output sink.
fnArchiveFormat detectZipFormat(const(ubyte)[] header)