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.
24 lines
771 B
24 lines
771 B
package dev.openrs2.compress.gzip
|
|
|
|
import dev.openrs2.util.io.SkipOutputStream
|
|
import java.io.ByteArrayInputStream
|
|
import java.io.InputStream
|
|
import java.io.OutputStream
|
|
import java.io.SequenceInputStream
|
|
import java.util.zip.Deflater
|
|
import java.util.zip.GZIPInputStream
|
|
|
|
public object Gzip {
|
|
private val HEADER = byteArrayOf(0x1F, 0x8B.toByte())
|
|
|
|
public fun createHeaderlessInputStream(input: InputStream): InputStream {
|
|
return GZIPInputStream(SequenceInputStream(ByteArrayInputStream(HEADER), input))
|
|
}
|
|
|
|
public fun createHeaderlessOutputStream(
|
|
output: OutputStream,
|
|
level: Int = Deflater.BEST_COMPRESSION
|
|
): OutputStream {
|
|
return GzipLevelOutputStream(SkipOutputStream(output, HEADER.size.toLong()), level)
|
|
}
|
|
}
|
|
|