@ -1,12 +1,11 @@
package dev.openrs2.common.io
package dev.openrs2.common.io
import java.io.FilterOutputStream
import java.io.OutputStream
import java.io.OutputStream
class SkipOutputStream ( out : OutputStream , private var skipBytes : Long ) : Filter OutputStream( out ) {
class SkipOutputStream ( private val out : OutputStream , private var skipBytes : Long ) : OutputStream ( ) {
override fun write ( b : Int ) {
override fun write ( b : Int ) {
if ( skipBytes == 0L ) {
if ( skipBytes == 0L ) {
super . write ( b )
out . write ( b )
} else {
} else {
skipBytes --
skipBytes --
}
}
@ -14,10 +13,18 @@ class SkipOutputStream(out: OutputStream, private var skipBytes: Long) : FilterO
override fun write ( b : ByteArray , off : Int , len : Int ) {
override fun write ( b : ByteArray , off : Int , len : Int ) {
if ( len >= skipBytes ) {
if ( len >= skipBytes ) {
super . write ( b , off + skipBytes . toInt ( ) , len - skipBytes . toInt ( ) )
out . write ( b , off + skipBytes . toInt ( ) , len - skipBytes . toInt ( ) )
skipBytes = 0
skipBytes = 0
} else {
} else {
skipBytes -= len
skipBytes -= len
}
}
}
}
override fun flush ( ) {
out . flush ( )
}
override fun close ( ) {
out . close ( )
}
}
}