mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
config: create the config dir recursively for edit
This commit is contained in:
@ -9,16 +9,9 @@ pub fn open(alloc_gpa: Allocator) !void {
|
|||||||
const config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
|
const config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
|
||||||
defer alloc_gpa.free(config_path);
|
defer alloc_gpa.free(config_path);
|
||||||
|
|
||||||
// Check if the directory exists, create it if it doesn't. This dirname
|
// Create config directory recursively.
|
||||||
// call should always succeed but we still check for errors just in case,
|
|
||||||
// no harm if we skip this step the open may just fail.
|
|
||||||
if (std.fs.path.dirname(config_path)) |config_dir| {
|
if (std.fs.path.dirname(config_path)) |config_dir| {
|
||||||
_ = std.fs.makeDirAbsolute(config_dir) catch |err| {
|
try std.fs.cwd().makePath(config_dir);
|
||||||
switch (err) {
|
|
||||||
error.PathAlreadyExists => {},
|
|
||||||
else => return err,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to create file and go on if it already exists
|
// Try to create file and go on if it already exists
|
||||||
|
Reference in New Issue
Block a user