ArchiveWriter class abstract

Writes entries to a ByteSink in one archive format, the SPI a format package implements for writing, and what application code drives via the Archive.create facade. The write mirror of ArchiveReader.

Contract

  • Entries are written in call order (archives are sequential). Content for addStream is consumed as a single-subscription stream with bounded memory.
  • addStream/addBytes/addEntry return the resulting ArchiveEntry (with computed CRC and sizes), so a write-then-read round trip is symmetric.
  • Every path is validated (rejecting absolute paths and .. escapes); see addStream.
  • close finalizes the archive (e.g. TAR end blocks, the ZIP central directory) and must be called exactly once; it does not close the underlying ByteSink (the caller owns it).

Constructors

ArchiveWriter()

Properties

format ArchiveWriteFormat
The format this writer produces.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addBytes(ArchiveEntrySpec spec, Uint8List content) Future<ArchiveEntry>
Writes a file entry from in-memory content (sugar for addStream with the size known).
addEntry(ArchiveEntrySpec spec) Future<ArchiveEntry>
Writes a metadata-only entry: a directory, symlink, hardlink, or other contentless type. Throws ArgumentError for a file-typed spec.
addStream(ArchiveEntrySpec spec, Stream<Uint8List> content, {required int size}) Future<ArchiveEntry>
Writes a file entry, streaming content (exactly size bytes) with bounded memory.
close() Future<void>
Finalizes the archive. Idempotent-safe to call once; further add* calls afterward throw ArchiveClosedException. Does not close the ByteSink.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited