Fix platform declarations in mirai-core-utils

This commit is contained in:
Him188 2021-02-25 09:41:05 +08:00
parent 2c14f0016f
commit f010b1150c
4 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,20 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:JvmMultifileClass
@file:Suppress("NOTHING_TO_INLINE")
package net.mamoe.mirai.utils
import android.util.Base64
public actual fun ByteArray.encodeToBase64(): String {
return Base64.encodeToString(this, Base64.DEFAULT)
}

View File

@ -152,8 +152,7 @@ public fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, len
public inline fun ByteArray.encodeToString(offset: Int = 0, charset: Charset = Charsets.UTF_8): String =
kotlinx.io.core.String(this, charset = charset, offset = offset, length = this.size - offset)
public inline fun ByteArray.encodeToBase64(): String =
Base64.getEncoder().encodeToString(this)
public expect fun ByteArray.encodeToBase64(): String
public inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset): ByteReadPacket =
ByteReadPacket(this, offset = offset, length = length)

View File

@ -131,7 +131,7 @@ public fun Input.copyTo(out: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE
return bytesCopied
}
public inline fun <I : AutoCloseable, O : AutoCloseable, R> I.withOut(output: O, block: I.(output: O) -> R): R {
public inline fun <I : Closeable, O : Closeable, R> I.withOut(output: O, block: I.(output: O) -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}

View File

@ -0,0 +1,20 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:JvmMultifileClass
@file:Suppress("NOTHING_TO_INLINE")
package net.mamoe.mirai.utils
import java.util.*
public actual fun ByteArray.encodeToBase64(): String {
return Base64.getEncoder().encodeToString(this)
}