mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
Merge pull request #868 from der-teufel-programming/win-noxdg
os/xdg: Add `LOCALAPPDATA` as a fallback for `XDG_CONFIG_HOME` on Windows
This commit is contained in:
@ -22,13 +22,21 @@ pub const Options = struct {
|
||||
pub fn config(alloc: Allocator, opts: Options) ![]u8 {
|
||||
// First check the env var. On Windows we have to allocate so this tracks
|
||||
// both whether we have the env var and whether we own it.
|
||||
// on Windows we treat `LOCALAPPDATA` as a fallback for `XDG_CONFIG_HOME`
|
||||
const env_, const owned = switch (builtin.os.tag) {
|
||||
else => .{ std.os.getenv("XDG_CONFIG_HOME"), false },
|
||||
.windows => windows: {
|
||||
if (std.process.getEnvVarOwned(alloc, "XDG_CONFIG_HOME")) |env| {
|
||||
break :windows .{ env, true };
|
||||
} else |err| switch (err) {
|
||||
error.EnvironmentVariableNotFound => break :windows .{ null, false },
|
||||
error.EnvironmentVariableNotFound => {
|
||||
if (std.process.getEnvVarOwned(alloc, "LOCALAPPDATA")) |env| {
|
||||
break :windows .{ env, true };
|
||||
} else |err2| switch (err2) {
|
||||
error.EnvironmentVariableNotFound => break :windows .{ null, false },
|
||||
else => return err,
|
||||
}
|
||||
},
|
||||
else => return err,
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user