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.
30 lines
670 B
30 lines
670 B
package dev.openrs2.util.io
|
|
|
|
import java.io.OutputStream
|
|
|
|
class SkipOutputStream(private val out: OutputStream, private var skipBytes: Long) : OutputStream() {
|
|
override fun write(b: Int) {
|
|
if (skipBytes == 0L) {
|
|
out.write(b)
|
|
} else {
|
|
skipBytes--
|
|
}
|
|
}
|
|
|
|
override fun write(b: ByteArray, off: Int, len: Int) {
|
|
if (len > skipBytes) {
|
|
out.write(b, off + skipBytes.toInt(), len - skipBytes.toInt())
|
|
skipBytes = 0
|
|
} else {
|
|
skipBytes -= len
|
|
}
|
|
}
|
|
|
|
override fun flush() {
|
|
out.flush()
|
|
}
|
|
|
|
override fun close() {
|
|
out.close()
|
|
}
|
|
}
|
|
|