If read Tagless Envelope from ByteArray (see code), wrong calculation offset for data location.
fun load(name: String): Envelope? {
val entry = zipFile.getEntry(name)
if (entry == null || entry.isDirectory) {
return null
}
val bytes = zipFile.getInputStream(entry).readAllBytes()
val binary = bytes.asBinary()
val text = bytes.inputStream().bufferedReader().readText() // Смотрю содержимое в дебагерре
return formatPeeker(binary)?.let {
val partialEnvelope = binary.read {
it.run { readPartial() }
}
val offset: Int = partialEnvelope.dataOffset.toInt()
val size: Int = partialEnvelope.dataSize?.toInt() ?: (binary.size.toInt() - offset)
val cut_bytes = bytes.sliceArray(offset..(offset+size-1))
val text1 = cut_bytes.inputStream().bufferedReader().readText() // Смотрю содержимое в дебагерре
SimpleEnvelope(partialEnvelope.meta, cut_bytes.asBinary())
}
}
If read Tagless Envelope from ByteArray (see code), wrong calculation offset for data location.