like in this example
The problem I'm facing, is that
platform.posix.popen
and
platform.posix.pclose
are not available in the shared
sourceSet
.
Any idea why it is not resolved?
Dragos Rachieru
03/07/2022, 2:03 PM
The
build.gradle
part:
Copy code
val desktopMain by creating {
dependsOn(commonMain)
}
val linuxX64Main by getting {
dependsOn(desktopMain)
}
val mingwX64Main by getting {
dependsOn(desktopMain)
}
val macosX64Main by getting {
dependsOn(desktopMain)
}
Dragos Rachieru
03/07/2022, 2:04 PM
code
Copy code
actual fun runCommand(command: String) {
system(command)
}
actual fun awaitCommand(
command: String
): String {
val fp = popen(command, "r") ?: error("Failed to run command: $command")
val buffer = ByteArray(4096)
val returnString = StringBuilder()
var scan = fgets(buffer.refTo(0), buffer.size, fp)
if (scan != null) {
while (scan != NULL) {
returnString.append(scan!!.toKString())
scan = fgets(buffer.refTo(0), buffer.size, fp)
}
}
val status = pclose(fp)
if (status != 0) {
error("Command $command failed with status $status")
}
return returnString.toString()
}
Dragos Rachieru
03/07/2022, 2:04 PM
system
call works
m
msink
03/07/2022, 3:56 PM
I'm not sure, but maybe
popen
and
pclose
are not supported in mingw.
Does it work if comment out mingw support?