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.readLines(): List { val lines = mutableListOf() val buffer = ByteArray(4096) while (true) { val line = fgets(buffer.refTo(0), buffer.size, this) ?: break lines.add(line.toKString()) } return lines }