diff --git a/src/main.zig b/src/main.zig index 3f18bbe..0b8ed0b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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;