diff options
Diffstat (limited to 'okio/src/nonJvmMain/kotlin/okio/RealBufferedSink.kt')
-rw-r--r-- | okio/src/nonJvmMain/kotlin/okio/RealBufferedSink.kt | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/okio/src/nonJvmMain/kotlin/okio/RealBufferedSink.kt b/okio/src/nonJvmMain/kotlin/okio/RealBufferedSink.kt new file mode 100644 index 00000000..ed03094e --- /dev/null +++ b/okio/src/nonJvmMain/kotlin/okio/RealBufferedSink.kt @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2019 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package okio + +import okio.internal.commonClose +import okio.internal.commonEmit +import okio.internal.commonEmitCompleteSegments +import okio.internal.commonFlush +import okio.internal.commonTimeout +import okio.internal.commonToString +import okio.internal.commonWrite +import okio.internal.commonWriteAll +import okio.internal.commonWriteByte +import okio.internal.commonWriteDecimalLong +import okio.internal.commonWriteHexadecimalUnsignedLong +import okio.internal.commonWriteInt +import okio.internal.commonWriteIntLe +import okio.internal.commonWriteLong +import okio.internal.commonWriteLongLe +import okio.internal.commonWriteShort +import okio.internal.commonWriteShortLe +import okio.internal.commonWriteUtf8 +import okio.internal.commonWriteUtf8CodePoint + +internal actual class RealBufferedSink actual constructor( + actual val sink: Sink +) : BufferedSink { + actual var closed: Boolean = false + override val buffer = Buffer() + + override fun write(source: Buffer, byteCount: Long) = commonWrite(source, byteCount) + override fun write(byteString: ByteString) = commonWrite(byteString) + override fun write(byteString: ByteString, offset: Int, byteCount: Int) = + commonWrite(byteString, offset, byteCount) + override fun writeUtf8(string: String) = commonWriteUtf8(string) + override fun writeUtf8(string: String, beginIndex: Int, endIndex: Int) = + commonWriteUtf8(string, beginIndex, endIndex) + + override fun writeUtf8CodePoint(codePoint: Int) = commonWriteUtf8CodePoint(codePoint) + override fun write(source: ByteArray) = commonWrite(source) + override fun write(source: ByteArray, offset: Int, byteCount: Int) = + commonWrite(source, offset, byteCount) + + override fun writeAll(source: Source) = commonWriteAll(source) + override fun write(source: Source, byteCount: Long): BufferedSink = commonWrite(source, byteCount) + override fun writeByte(b: Int) = commonWriteByte(b) + override fun writeShort(s: Int) = commonWriteShort(s) + override fun writeShortLe(s: Int) = commonWriteShortLe(s) + override fun writeInt(i: Int) = commonWriteInt(i) + override fun writeIntLe(i: Int) = commonWriteIntLe(i) + override fun writeLong(v: Long) = commonWriteLong(v) + override fun writeLongLe(v: Long) = commonWriteLongLe(v) + override fun writeDecimalLong(v: Long) = commonWriteDecimalLong(v) + override fun writeHexadecimalUnsignedLong(v: Long) = commonWriteHexadecimalUnsignedLong(v) + override fun emitCompleteSegments() = commonEmitCompleteSegments() + override fun emit() = commonEmit() + override fun flush() = commonFlush() + override fun close() = commonClose() + override fun timeout() = commonTimeout() + override fun toString() = commonToString() +} |