start migration onto new dependencies

This commit is contained in:
2024-08-16 19:10:49 +06:00
parent 1a317f1455
commit a28448c3c1
31 changed files with 118 additions and 87 deletions

View File

@@ -11,6 +11,7 @@ kotlin {
commonMain {
dependencies {
api libs.klock
api libs.kt.io
}
}
jvmMain {

View File

@@ -1,5 +1,11 @@
package dev.inmo.micro_utils.common
import kotlinx.io.Buffer
import kotlinx.io.Source
import kotlinx.io.buffered
import kotlinx.io.files.Path
import kotlinx.io.files.SystemFileSystem
import kotlinx.io.readByteArray
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmInline
@@ -32,3 +38,17 @@ expect val MPPFile.bytesAllocator: SuspendByteArrayAllocator
fun MPPFile.bytesSync() = bytesAllocatorSync()
suspend fun MPPFile.bytes() = bytesAllocator()
val Path.filename: FileName
get() = FileName(name)
val Path.filesize: Long
get() = SystemFileSystem.metadataOrNull(this) ?.size ?.takeIf { it > -1 } ?: error("Path $filename does not exists or is folder")
val Path.bytesAllocatorSync: ByteArrayAllocator
get() = {
source().buffered().readByteArray()
}
val Path.bytesAllocator: SuspendByteArrayAllocator
get() = {
bytesAllocatorSync()
}
fun Path.source(): Source = SystemFileSystem.source(this).buffered()

View File

@@ -1,5 +1,6 @@
package dev.inmo.micro_utils.common
import kotlinx.io.files.Path
import org.khronos.webgl.ArrayBuffer
import org.w3c.dom.ErrorEvent
import org.w3c.files.*