mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
comment
This commit is contained in:
@ -7,21 +7,23 @@ const internal_os = @import("../os/main.zig");
|
|||||||
/// paths the main config file could be in.
|
/// paths the main config file could be in.
|
||||||
pub fn open(alloc_gpa: Allocator) !void {
|
pub fn open(alloc_gpa: Allocator) !void {
|
||||||
// default location
|
// default location
|
||||||
var config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
|
const config_path = config_path: {
|
||||||
|
const xdg_config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
|
||||||
|
|
||||||
if (comptime builtin.os.tag == .macos) {
|
if (comptime builtin.os.tag == .macos) macos: {
|
||||||
const xdg_config_exists = if (std.fs.accessAbsolute(config_path, std.fs.File.OpenFlags{})) true else |err| switch (err) {
|
if (std.fs.accessAbsolute(xdg_config_path, .{})) {
|
||||||
error.BadPathName => false,
|
break :macos;
|
||||||
error.FileNotFound => false,
|
} else |err| switch (err) {
|
||||||
else => true,
|
error.BadPathName, error.FileNotFound => {},
|
||||||
};
|
else => break :macos,
|
||||||
|
}
|
||||||
|
|
||||||
if (!xdg_config_exists) {
|
alloc_gpa.free(xdg_config_path);
|
||||||
alloc_gpa.free(config_path);
|
break :config_path try internal_os.macos.appSupportDir(alloc_gpa, "config");
|
||||||
config_path = try internal_os.macos.appSupportDir(alloc_gpa, "config");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
break :config_path xdg_config_path;
|
||||||
|
};
|
||||||
defer alloc_gpa.free(config_path);
|
defer alloc_gpa.free(config_path);
|
||||||
|
|
||||||
// Create config directory recursively.
|
// Create config directory recursively.
|
||||||
|
Reference in New Issue
Block a user