feat(main): check for Lua config and fallback to INI

Checks for the presence of a config.lua file.
If it fails to find it or read it, default to config.ini
This commit is contained in:
Titanium Brain 2026-07-11 09:54:36 +01:00
commit d3e6dd4814

View file

@ -237,8 +237,13 @@ pub fn main(init: std.process.Init) !void {
state.allocator.free(state.old_save_path);
};
// TODO do not hardcode config file name
const config_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "config.lua" });
// Test for presence of Lua config file first
// If it fails, fall back to ini
var config_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "config.lua" });
if (std.Io.Dir.accessAbsolute(state.io, config_path, .{})) |_| {} else |_| {
state.allocator.free(config_path);
config_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "config.ini" });
}
defer state.allocator.free(config_path);
custom.binds = .empty;