commonMain.dev.inmo.micro_utils.common.MPPFile.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro_utils.common-jvm Show documentation
Show all versions of micro_utils.common-jvm Show documentation
It is set of projects with micro tools for avoiding of routines coding
The newest version!
package dev.inmo.micro_utils.common
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmInline
@Serializable
@JvmInline
value class FileName(val string: String) {
val name: String
get() = withoutSlashAtTheEnd.takeLastWhile { it != '/' }
val extension: String
get() = name.takeLastWhile { it != '.' }
val nameWithoutExtension: String
get() {
val filename = name
return filename.indexOfLast { it == '.' }.takeIf { it > -1 } ?.let {
filename.substring(0, it)
} ?: filename
}
val withoutSlashAtTheEnd: String
get() = string.dropLastWhile { it == '/' }
override fun toString(): String = string
}
expect class MPPFile
expect val MPPFile.filename: FileName
expect val MPPFile.filesize: Long
expect val MPPFile.bytesAllocatorSync: ByteArrayAllocator
expect val MPPFile.bytesAllocator: SuspendByteArrayAllocator
fun MPPFile.bytesSync() = bytesAllocatorSync()
suspend fun MPPFile.bytes() = bytesAllocator()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy