mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-10-25 14:17:14 +00:00
experimentally add linuxx64 and mingwx64 as target platforms
This commit is contained in:
1 parent
d23e005985
commit
617dfb54e0
27 files changed
+1248
-1087
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package dev.inmo.micro_utils.ktor.common
|
||||
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
import io.ktor.utils.io.bits.Memory
|
||||
import io.ktor.utils.io.bits.loadByteArray
|
||||
import io.ktor.utils.io.core.Input
|
||||
import okio.FileSystem
|
||||
import okio.Path
|
||||
|
||||
private class FileInput(
|
||||
private val path: Path
|
||||
) : Input() {
|
||||
private val openedFile = FileSystem.SYSTEM.openReadOnly(path)
|
||||
override fun closeSource() {
|
||||
openedFile.close()
|
||||
}
|
||||
|
||||
override fun fill(destination: Memory, offset: Int, length: Int): Int {
|
||||
val byteArray = ByteArray(length)
|
||||
val read = openedFile.read(offset.toLong(), byteArray, 0, length)
|
||||
destination.loadByteArray(
|
||||
offset,
|
||||
byteArray,
|
||||
count = length
|
||||
)
|
||||
return read
|
||||
}
|
||||
}
|
||||
|
||||
actual fun MPPFile.input(): Input {
|
||||
return FileInput(this)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.inmo.micro_utils.ktor.common
|
||||
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
import io.ktor.utils.io.bits.Memory
|
||||
import io.ktor.utils.io.bits.loadByteArray
|
||||
import io.ktor.utils.io.core.Input
|
||||
import okio.FileSystem
|
||||
import okio.Path
|
||||
|
||||
private class FileInput(
|
||||
private val path: Path
|
||||
) : Input() {
|
||||
private val openedFile = FileSystem.SYSTEM.openReadOnly(path)
|
||||
override fun closeSource() {
|
||||
openedFile.close()
|
||||
}
|
||||
|
||||
override fun fill(destination: Memory, offset: Int, length: Int): Int {
|
||||
val byteArray = ByteArray(length)
|
||||
val read = openedFile.read(offset.toLong(), byteArray, 0, length)
|
||||
destination.loadByteArray(
|
||||
offset,
|
||||
byteArray,
|
||||
count = length
|
||||
)
|
||||
return read
|
||||
}
|
||||
}
|
||||
|
||||
actual fun MPPFile.input(): Input {
|
||||
return FileInput(this)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user