Make app run on Android (WIP)

This commit is contained in:
Christian Basler
2025-07-14 21:34:13 +02:00
parent 1fb3b39590
commit 1800174087
6 changed files with 72 additions and 32 deletions

View File

@@ -6,10 +6,8 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlin.io.path.Path
import kotlin.io.path.createDirectories
import kotlin.io.path.createFile
import kotlin.io.path.isDirectory
import kotlin.io.path.notExists
import kotlin.io.path.writeText
import kotlin.time.Clock
import kotlin.time.ExperimentalTime
@@ -21,17 +19,15 @@ actual fun CoroutineScope.logGame(game: Game) {
launch(Dispatchers.IO) {
val dirName = """${System.getProperty("user.home")}/.yaep"""
val dir = Path(dirName)
if (dir.notExists()) {
dir.createDirectories()
} else if (!dir.isDirectory()) {
log.error { "Yaep data directory already exists and is not a directory: $dir" }
log.debug { "Game: $game" }
} else {
if (dir.isDirectory()) {
val fileName = "$dirName/${Clock.System.now()}.yaep"
Path(fileName)
.createFile()
.writeText(game.toString())
log.info { "Saved game to $fileName" }
} else {
log.debug { "Yaep data directory does not exist or is not a directory: $dir" }
log.debug { "Game: $game" }
}
}
}