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