in lib/src/main/kotlin/org/jetbrains/zip/signer/datasource/SeekableByteChannelDataSource.kt [66:85]
override fun copyTo(offset: Long, size: Int, dest: ByteBuffer) {
val sourceSize = size()
checkChunkValid(offset, size.toLong(), sourceSize)
if (size == 0) return
if (size > dest.remaining()) throw BufferOverflowException()
var offsetInFile = this.offset + offset
var remaining = size
val prevLimit = dest.limit()
try {
dest.limit(dest.position() + size)
while (remaining > 0) {
channel.position(offsetInFile)
val chunkSize: Int = channel.read(dest)
offsetInFile += chunkSize.toLong()
remaining -= chunkSize
}
} finally {
dest.limit(prevLimit)
}
}