Skip to content

Commit b7defb3

Browse files
committed
Kotlin 2.3.0 compilation fix related to createTempFile
1 parent e7016a9 commit b7defb3

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ composeCharts = "0.2.0"
44
kopus = "1.6"
55
kotlin = "2.3.0"
66
android-compileSdk = "36"
7-
android-minSdk = "24"
7+
android-minSdk = "26"
88
android-targetSdk = "36"
99
coreKtx = "1.17.0"
1010
junit = "4.13.2"

kopus/src/androidAndJvmMain/kotlin/eu/buney/kopus/OpusLoader.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
*/
77
package eu.buney.kopus
88

9-
import java.io.File
9+
import java.nio.file.Path
1010
import java.util.concurrent.atomic.AtomicBoolean
11+
import kotlin.io.path.createTempFile
12+
import kotlin.io.path.outputStream
1113

1214
/**
1315
* Handles loading of the Opus JNI native library.
@@ -51,15 +53,14 @@ object OpusLoader {
5153

5254
val resourcePath = "/native/$osPath/$archPath/$libName"
5355
val extracted = extractToTemp(resourcePath)
54-
System.load(extracted.absolutePath)
56+
System.load(extracted.toAbsolutePath().toString())
5557
}
5658

57-
private fun extractToTemp(path: String): File {
59+
private fun extractToTemp(path: String): Path {
5860
val temp = createTempFile("libopus_jni")
5961
OpusLoader::class.java.getResourceAsStream(path)?.use { input ->
6062
temp.outputStream().use { output -> input.copyTo(output) }
6163
} ?: throw RuntimeException("Could not find $path in resources!")
62-
temp.deleteOnExit()
6364
return temp
6465
}
6566
}

0 commit comments

Comments
 (0)