From a0ceeaa121e847523d7a1d64b81456d9beb33340 Mon Sep 17 00:00:00 2001 From: MauriceElliott Date: Mon, 30 Dec 2024 02:02:10 +0000 Subject: [PATCH] changed it so if no file exists, it will create one in the appsupport directory. --- src/config/edit.zig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config/edit.zig b/src/config/edit.zig index 2af792985..e17b07b8a 100644 --- a/src/config/edit.zig +++ b/src/config/edit.zig @@ -13,11 +13,17 @@ pub fn open(alloc_gpa: Allocator) !void { if (comptime builtin.os.tag == .macos) macos: { // On macOS, use the XDG path if the app support path doesn't exist. const app_support_path = try internal_os.macos.appSupportDir(alloc_gpa, "config"); + + // If no configuration file currently exist, it should be created in app support. + var no_config_file = false; + if (std.fs.accessAbsolute(app_support_path, .{})) { alloc_gpa.free(xdg_config_path); break :config_path app_support_path; } else |err| switch (err) { - error.BadPathName, error.FileNotFound => {}, + error.BadPathName, error.FileNotFound => { + no_config_file = true; + }, else => break :macos, } @@ -25,9 +31,12 @@ pub fn open(alloc_gpa: Allocator) !void { alloc_gpa.free(app_support_path); break :macos; } else |err| switch (err) { - error.BadPathName, error.FileNotFound => {}, + error.BadPathName, error.FileNotFound => { + no_config_file = true; + }, else => break :macos, } + if (no_config_file) break :config_path app_support_path; } break :config_path xdg_config_path;