From e44236b0ce3e3d02ed390c9855570e72205b989f Mon Sep 17 00:00:00 2001 From: hinerm Date: Mon, 20 May 2024 15:26:32 -0500 Subject: [PATCH] Look for config files in the configDir Instead of appDir. --- src/commonMain/kotlin/vars.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/commonMain/kotlin/vars.kt b/src/commonMain/kotlin/vars.kt index a091f29..773634a 100644 --- a/src/commonMain/kotlin/vars.kt +++ b/src/commonMain/kotlin/vars.kt @@ -8,15 +8,17 @@ class Vars(appDir: File, configDir: File, exeFile: File?) { vars["config-dir"] = configDir.path if (exeFile?.exists == true) vars["executable"] = exeFile.path - // Read matching .cfg files, containing key=value pairs, from the app-dir. - var cfgName = exeFile?.base?.name + // Build the list of config files val cfgFiles = mutableListOf() + var cfgName = exeFile?.base?.name while (cfgName != null) { - val cfgFile = appDir / "$cfgName.cfg" + val cfgFile = configDir / "$cfgName.cfg" if (cfgFile.exists) cfgFiles += cfgFile val dash = cfgName.lastIndexOf("-") cfgName = if (dash < 0) null else cfgName.substring(0, dash) } + + // Read matching .cfg files, containing key=value pairs. for (cfgFile in cfgFiles.reversed()) { vars += cfgFile.lines() .filter { it.indexOf("=") >= 0 }