diff --git a/mirai-core-api/compatibility-validation/android/api/android.api b/mirai-core-api/compatibility-validation/android/api/android.api index a8342399e..43dc90cf2 100644 --- a/mirai-core-api/compatibility-validation/android/api/android.api +++ b/mirai-core-api/compatibility-validation/android/api/android.api @@ -5881,6 +5881,7 @@ public abstract interface class net/mamoe/mirai/utils/ExternalResource : java/io public static fun create (Ljava/io/RandomAccessFile;Ljava/lang/String;Z)Lnet/mamoe/mirai/utils/ExternalResource; public static fun create ([B)Lnet/mamoe/mirai/utils/ExternalResource; public static fun create ([BLjava/lang/String;)Lnet/mamoe/mirai/utils/ExternalResource; + public static synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource; public abstract fun getClosed ()Lkotlinx/coroutines/Deferred; public abstract fun getFormatName ()Ljava/lang/String; public abstract fun getMd5 ()[B @@ -5945,6 +5946,7 @@ public final class net/mamoe/mirai/utils/ExternalResource$Companion { public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/InputStream;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource; public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/RandomAccessFile;Ljava/lang/String;ZILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource; public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;[BLjava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource; + public final synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource; public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt; public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lnet/mamoe/mirai/utils/RemoteFile$ProgressionCallback;)Lnet/mamoe/mirai/message/MessageReceipt; diff --git a/mirai-core-api/compatibility-validation/jvm/api/jvm.api b/mirai-core-api/compatibility-validation/jvm/api/jvm.api index e1605441d..3b727188a 100644 --- a/mirai-core-api/compatibility-validation/jvm/api/jvm.api +++ b/mirai-core-api/compatibility-validation/jvm/api/jvm.api @@ -5881,6 +5881,7 @@ public abstract interface class net/mamoe/mirai/utils/ExternalResource : java/io public static fun create (Ljava/io/RandomAccessFile;Ljava/lang/String;Z)Lnet/mamoe/mirai/utils/ExternalResource; public static fun create ([B)Lnet/mamoe/mirai/utils/ExternalResource; public static fun create ([BLjava/lang/String;)Lnet/mamoe/mirai/utils/ExternalResource; + public static synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource; public abstract fun getClosed ()Lkotlinx/coroutines/Deferred; public abstract fun getFormatName ()Ljava/lang/String; public abstract fun getMd5 ()[B @@ -5945,6 +5946,7 @@ public final class net/mamoe/mirai/utils/ExternalResource$Companion { public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/InputStream;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource; public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;Ljava/io/RandomAccessFile;Ljava/lang/String;ZILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource; public static synthetic fun create$default (Lnet/mamoe/mirai/utils/ExternalResource$Companion;[BLjava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/utils/ExternalResource; + public final synthetic fun createAutoCloseable (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/utils/ExternalResource; public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt; public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun sendAsFile (Lnet/mamoe/mirai/utils/ExternalResource;Lnet/mamoe/mirai/contact/FileSupported;Ljava/lang/String;Lnet/mamoe/mirai/utils/RemoteFile$ProgressionCallback;)Lnet/mamoe/mirai/message/MessageReceipt; diff --git a/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt b/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt index 905178c5d..e6888fbf2 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 Mamoe Technologies and contributors. + * Copyright 2019-2022 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. @@ -227,6 +227,24 @@ public interface ExternalResource : Closeable { // endregion + + /* note: + 于 2.8.0-M1 添加 (#1392) + + 于 2.8.0-RC 移动至 `toExternalResource`(#1588) + */ + @JvmName("createAutoCloseable") + @JvmStatic + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Moved to `toExternalResource()`", + replaceWith = ReplaceWith("resource.toAutoCloseable()"), + ) + @DeprecatedSinceMirai(errorSince = "2.8", hiddenSince = "2.10") + public fun createAutoCloseable(resource: ExternalResource): ExternalResource { + return resource.toAutoCloseable() + } + /////////////////////////////////////////////////////////////////////////// // region sendAsImageTo /////////////////////////////////////////////////////////////////////////// @@ -349,7 +367,7 @@ public interface ExternalResource : Closeable { * @see RemoteFile.path * @see RemoteFile.upload */ - @Suppress("DEPRECATION","DEPRECATION_ERROR") + @Suppress("DEPRECATION", "DEPRECATION_ERROR") @JvmStatic @JvmBlockingBridge @JvmOverloads