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.
33 lines
1.3 KiB
33 lines
1.3 KiB
4 years ago
|
package org.openrs2.compress.lzma
|
||
4 years ago
|
|
||
|
import com.google.common.io.LittleEndianDataInputStream
|
||
|
import com.google.common.io.LittleEndianDataOutputStream
|
||
|
import org.tukaani.xz.LZMA2Options
|
||
|
import org.tukaani.xz.LZMAInputStream
|
||
|
import org.tukaani.xz.LZMAOutputStream
|
||
|
import java.io.InputStream
|
||
|
import java.io.OutputStream
|
||
|
|
||
4 years ago
|
public object Lzma {
|
||
|
public val BEST_SPEED: LZMA2Options = LZMA2Options(LZMA2Options.PRESET_MIN)
|
||
|
public val DEFAULT_COMPRESSION: LZMA2Options = LZMA2Options(LZMA2Options.PRESET_DEFAULT)
|
||
|
public val BEST_COMPRESSION: LZMA2Options = LZMA2Options(LZMA2Options.PRESET_MAX)
|
||
4 years ago
|
|
||
4 years ago
|
public fun createHeaderlessInputStream(input: InputStream, length: Long): InputStream {
|
||
4 years ago
|
val headerInput = LittleEndianDataInputStream(input)
|
||
|
|
||
|
val properties = headerInput.readByte()
|
||
|
val dictionarySize = headerInput.readInt()
|
||
|
|
||
|
return LZMAInputStream(input, length, properties, dictionarySize)
|
||
|
}
|
||
|
|
||
4 years ago
|
public fun createHeaderlessOutputStream(output: OutputStream, options: LZMA2Options): OutputStream {
|
||
4 years ago
|
val headerOutput = LittleEndianDataOutputStream(output)
|
||
|
headerOutput.writeByte((options.pb * 5 + options.lp) * 9 + options.lc)
|
||
|
headerOutput.writeInt(options.dictSize)
|
||
|
|
||
|
return LZMAOutputStream(output, options, false)
|
||
|
}
|
||
|
}
|