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 }