Fix native implementation

This commit is contained in:
2026-02-16 17:53:50 +01:00
parent 2679f688d5
commit a80bb11652
4 changed files with 60 additions and 14 deletions

View File

@@ -0,0 +1,17 @@
package com.infendro.shell
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.refTo
import kotlinx.cinterop.toKString
import platform.posix.FILE
import platform.posix.fgets
internal fun CPointer<FILE>.readLines(): List<String> {
val lines = mutableListOf<String>()
val buffer = ByteArray(4096)
while (true) {
val line = fgets(buffer.refTo(0), buffer.size, this) ?: break
lines.add(line.toKString())
}
return lines
}