Fixed string(), added lines() support

This commit is contained in:
nathan 2020-08-10 17:41:54 +02:00
parent db1118a733
commit 1697108b5c

View File

@ -82,11 +82,9 @@ open class AsyncProcessOutput(private val channel: Channel<Byte>) {
/** /**
* @return output of the finished process converted to a String using platform's default encoding. * @return output of the finished process converted to a String using platform's default encoding.
*/ */
val string: String suspend fun string(): String {
get() { return String(getBuffered())
// return String(getBuffered()) }
return ""
}
/** /**
* @return output of the finished process converted to UTF-8 String. * @return output of the finished process converted to UTF-8 String.
@ -109,4 +107,27 @@ open class AsyncProcessOutput(private val channel: Channel<Byte>) {
throw IllegalStateException(e.message) throw IllegalStateException(e.message)
} }
} }
/**
* @return output lines of the finished process converted using platform's default encoding.
*/
suspend fun lines(): List<String> {
return ProcessOutput.getLinesFrom(string())
}
/**
* @return output lines of the finished process converted using UTF-8.
*/
suspend fun linesAsUtf8(): List<String> {
return ProcessOutput.getLinesFrom(utf8())
}
/**
* @param charset The name of a supported char set.
*
* @return output lines of the finished process converted using a given char set.
*/
suspend fun getLines(charset: Charset): List<String> {
return ProcessOutput.getLinesFrom(getString(charset))
}
} }