mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-21 18:29:13 +08:00
update
This commit is contained in:
parent
1eae0932af
commit
e9b64c83f4
@ -96,8 +96,28 @@ fun ByteArray.dataInputStream(): DataInputStream = DataInputStream(this.inputStr
|
|||||||
/**
|
/**
|
||||||
* Reset and skip(position)
|
* Reset and skip(position)
|
||||||
*/
|
*/
|
||||||
fun <N : Number> DataInputStream.goto(position: N): DataInputStream {
|
infix fun <N : Number> DataInputStream.goto(position: N): DataInputStream {
|
||||||
this.reset()
|
this.reset()
|
||||||
this.skip(position.toLong());
|
this.skip(position.toLong());
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <N : Number> DataInputStream.readNBytes(position: N, length: Int): ByteArray {
|
||||||
|
this.goto(position)
|
||||||
|
return this.readNBytes(length)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <N : Number> DataInputStream.readInt(position: N): Int {
|
||||||
|
this.goto(position)
|
||||||
|
return this.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <N : Number> DataInputStream.readByte(position: N): Byte {
|
||||||
|
this.goto(position)
|
||||||
|
return this.readByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <N : Number> DataInputStream.readShort(position: N): Short {
|
||||||
|
this.goto(position)
|
||||||
|
return this.readShort();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user