ZipDirectory class final
A ZIP archive's directory, read from the end of the file alone: every entry's path, sizes and flags, checked by every rule of ZipArchive.read that needs only the directory. What a tool reads to check an archive on a server — with HTTP ranges — before downloading all of it; readContent then fetches and unpacks one small file.
Where each entry's data lies is only known once its local header is read, so overlapping and overlong data are checked against the least room each entry can take: that refuses only archives the full reader refuses too, but not every one. ZipArchive.read stays the authority.
Constructors
- ZipDirectory.fromTail(Uint8List tail, {required int totalLength, ZipLimits limits = const ZipLimits()})
-
Reads the directory from
tail, the last bytes of atotalLength-byte archive. Throws ZipNeedsBytes whentaildoesn't reach back far enough, ZipFormatException or UnsafePathException.factory
Properties
-
entries
→ List<
ZipEntry> -
Every entry, files and folders, in the archive's order.
final
-
files
→ Iterable<
ZipEntry> -
The file entries only.
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
- totalLength → int
-
The archive's length in bytes.
final
- totalSize → int
-
The total unpacked size of every file, in bytes.
no setter
Methods
-
contentFrom(
ZipEntry entry, Uint8List bytes, {required int start}) → Uint8List -
The unpacked bytes of
entryfrombytes— the archive's bytes fromstarton — once its local header agrees with the directory, checked against its size and CRC-32. -
entry(
String path) → ZipEntry? -
The entry at
path, or null. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readContent(
ZipEntry entry, Future< Uint8List> read(int start, int end)) → Future<Uint8List> -
entryunpacked, fetching its bytes throughreadas fetch does. The caller limits how large an entry it reads this way. -
spanOf(
ZipEntry entry) → ({int end, int start}) -
The bytes of the archive (start included, end not) contentFrom needs
to unpack
entry: its local header, with room for an extra field, and its data. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fetch(
Future< Uint8List> read(int start, int end), int totalLength, {ZipLimits limits = const ZipLimits(), int maxDirectoryBytes = 8 << 20}) → Future<ZipDirectory> -
Reads the directory of a
totalLength-byte archive throughread, which fetches bytesstartup toend(end not included) — the last tailBytes first, then the central directory when it starts before them, if it is at mostmaxDirectoryByteslong.