MicroUtils/common/src/linuxX64Main/kotlin/ActualMPPFile.kt

37 lines
660 B
Kotlin
Raw Normal View History

2023-04-03 09:49:46 +00:00
package dev.inmo.micro_utils.common
import okio.FileSystem
import okio.Path
import okio.use
2023-04-03 09:49:46 +00:00
actual typealias MPPFile = Path
2023-04-03 09:49:46 +00:00
/**
* @suppress
*/
2023-04-03 09:49:46 +00:00
actual val MPPFile.filename: FileName
get() = FileName(toString())
/**
* @suppress
*/
2023-04-03 09:49:46 +00:00
actual val MPPFile.filesize: Long
get() = FileSystem.SYSTEM.openReadOnly(this).use {
it.size()
2023-04-03 09:49:46 +00:00
}
/**
* @suppress
*/
2023-04-03 09:49:46 +00:00
actual val MPPFile.bytesAllocatorSync: ByteArrayAllocator
get() = {
FileSystem.SYSTEM.read(this) {
readByteArray()
2023-04-03 09:49:46 +00:00
}
}
/**
* @suppress
*/
2023-04-03 09:49:46 +00:00
actual val MPPFile.bytesAllocator: SuspendByteArrayAllocator
get() = {
bytesAllocatorSync()
}