ZipFileArchive

class ZipFileArchive : ReadOnlyArchive

ReadOnlyArchive backed by java.util.zip.ZipFile over a direct filesystem path (JVM + Android). ZipFile opens with random access, reads only the central directory up front, and inflates individual entries on demand — so opening a 15 GB archive does not read 15 GB. Requires a real file path; the app is expected to hand us one it can open directly (no SAF content:// fd handling needed for that case). ZIP64 is supported on modern JVM/Android.

TODO (mobile scale): ZipFile retains a ZipEntry for every archive entry — for a multi-million entry package that is hundreds of MB of RAM. The production path should be a CompactIndexArchive built on RandomAccessFile: parse EOCD64 + the central directory once into an open-addressed pathHash -> (offset, size) long[] index (3TZ can shortcut this via its @3dtilesIndex1@ index entry), drop the entry names, and pread entries by offset. This ZipFile impl is fine for smaller datasets; measure entry count on a real dataset before shipping it as the default.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val entryCount: Int

Number of entries in the archive (diagnostic; also a proxy for index-memory pressure).

Functions

Link copied to clipboard
open override fun close()

Release the underlying file handle. Idempotent.

Link copied to clipboard
open override fun hasEntry(path: String): Boolean

True when path resolves to an entry. Cheap index/metadata lookup, no full read.

Link copied to clipboard
open suspend override fun readEntry(path: String): ByteArray?

Read and decompress the entry at path (archive-internal path, e.g. content/0/0.b3dm or nodes/1/geometries/0.bin). Returns null when the entry is absent. Runs the blocking read on an IO dispatcher in the implementation. Throws only on genuine IO failure, not on a miss.