Fix issues
Some checks failed
PRs & Pushes / test (push) Failing after 2m34s
PRs & Pushes / build-jars (push) Failing after 2m33s
PRs & Pushes / build-apidoc (push) Failing after 1m55s

This commit is contained in:
JeremyStar™ 2024-12-29 05:02:54 +01:00
parent e8535cd25a
commit 36da65b45e
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
5 changed files with 30 additions and 7 deletions

View file

@ -19,4 +19,23 @@
package de.staropensource.engine.base.platform
expect fun platformTerminate(exitcode: UByte)
/**
* Terminates the platform.
*
* @since v1-alpha10
*/
internal expect fun platformTerminate(exitcode: UByte)
/**
* Returns the time in milliseconds.
*
* Should only be used for
* comparing time intervals.
* **Should not be stored as
* this method may return a
* timestamp from platform
* to platform.**
*
* @since v1-alpha10
*/
internal expect fun platformMilliseconds(): ULong

View file

@ -37,8 +37,10 @@ abstract class ProcessPlatform (
/**
* Initializes the process.
*
* @throws Throwable on error
* @since v1-alpha10
*/
@Throws(Throwable::class)
abstract fun start()
/**

View file

@ -22,6 +22,7 @@ package de.staropensource.engine.base.utility
import de.staropensource.engine.base.type.environment.GraphicsCard
import de.staropensource.engine.base.type.environment.OperatingSystem
import kotlinx.datetime.Instant
import kotlin.jvm.JvmStatic
/**
* Provides information about the

View file

@ -27,8 +27,8 @@ import de.staropensource.engine.base.implementable.stream.ReadStream
import de.staropensource.engine.base.implementable.stream.Stream
import de.staropensource.engine.base.implementable.stream.WriteStream
import de.staropensource.engine.base.platform.ProcessPlatform
import de.staropensource.engine.base.platform.platformMilliseconds
import de.staropensource.engine.base.platform.platformProcessCreate
import java.io.IOException
import kotlin.Throws
/**
@ -161,7 +161,7 @@ class Process : PlatformData {
// Set properties
this.executable = executable
this.arguments = arguments
this.workingDirectory = workingDirectory ?: FileAccess(System.getProperty("user.dir"))
this.workingDirectory = workingDirectory ?: FileAccess.temporaryCacheDirectory!!
this.launchedWithFreshEnvironment = freshEnvironment
this.environmentVariables = environmentVariables.toMap()
this.exitEvents = exitEvents.toMutableList()
@ -184,8 +184,8 @@ class Process : PlatformData {
standardOutput.watch()
standardError.watch()
}
} catch (exception: IOException) {
throw IOAccessException("Unable to spawn new process", exception)
} catch (throwable: Throwable) {
throw IOAccessException("Unable to spawn new process", throwable)
}
}
@ -269,9 +269,9 @@ class Process : PlatformData {
* @since v1-alpha10
*/
fun waitForExit(maxTime: ULong = 0UL): Process {
val maxTimeReal: Long = System.currentTimeMillis().plus(maxTime.toLong())
val maxTimeReal: ULong = platformMilliseconds()
while (maxTime == 0UL || System.currentTimeMillis() < maxTimeReal)
while (maxTime == 0UL || platformMilliseconds() < maxTimeReal)
if (!isAlive())
break

View file

@ -20,3 +20,4 @@
package de.staropensource.engine.base.platform
actual fun platformTerminate(exitcode: UByte) = Runtime.getRuntime().exit(exitcode.toInt())
actual fun platformMilliseconds(): ULong = System.currentTimeMillis().toULong()