RandomAccessSource

A seekable, random-access byte source. Every container reader works against this read contract. ZIP "browse without extract" (read the central directory at the tail) and single-entry extract (seek to one local header) both need offset reads rather than a forward-only stream.

ByteArrayRandomAccessSource is the only implementation shipped, so an archive has to be fully in memory before a reader can open it. Implement this interface yourself to back a reader with a real file handle.

Inheritors

Properties

Link copied to clipboard
abstract val size: Long

Total size in bytes.

Functions

Link copied to clipboard
open fun close()

Release any underlying handle. No-op for in-memory sources.

Link copied to clipboard
abstract fun read(offset: Long, into: ByteArray, intoOffset: Int = 0, length: Int = into.size): Int

Read up to length bytes starting at absolute offset into into at intoOffset. Returns the number of bytes read, or -1 at end of source.

Link copied to clipboard

Read exactly length bytes at offset, or fail. Convenience over RandomAccessSource.read.