Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
914 B
23 lines
914 B
4 years ago
|
package org.openrs2.compress.bzip2
|
||
4 years ago
|
|
||
|
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream
|
||
|
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream
|
||
4 years ago
|
import org.openrs2.util.io.SkipOutputStream
|
||
4 years ago
|
import java.io.ByteArrayInputStream
|
||
|
import java.io.InputStream
|
||
|
import java.io.OutputStream
|
||
|
import java.io.SequenceInputStream
|
||
|
|
||
4 years ago
|
public object Bzip2 {
|
||
4 years ago
|
private const val BLOCK_SIZE = 1
|
||
|
private val HEADER = byteArrayOf('B'.toByte(), 'Z'.toByte(), 'h'.toByte(), ('0' + BLOCK_SIZE).toByte())
|
||
|
|
||
4 years ago
|
public fun createHeaderlessInputStream(input: InputStream): InputStream {
|
||
4 years ago
|
return BZip2CompressorInputStream(SequenceInputStream(ByteArrayInputStream(HEADER), input))
|
||
|
}
|
||
|
|
||
4 years ago
|
public fun createHeaderlessOutputStream(output: OutputStream): OutputStream {
|
||
4 years ago
|
return BZip2CompressorOutputStream(SkipOutputStream(output, HEADER.size.toLong()), BLOCK_SIZE)
|
||
|
}
|
||
|
}
|