mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
os: directory functions should prefer cached home if available
This fixes tests as well if env vars are set.
This commit is contained in:
@ -58,6 +58,15 @@ fn dir(
|
|||||||
opts: Options,
|
opts: Options,
|
||||||
internal_opts: InternalOptions,
|
internal_opts: InternalOptions,
|
||||||
) ![]u8 {
|
) ![]u8 {
|
||||||
|
// If we have a cached home dir, use that.
|
||||||
|
if (opts.home) |home| {
|
||||||
|
return try std.fs.path.join(alloc, &[_][]const u8{
|
||||||
|
home,
|
||||||
|
internal_opts.default_subdir,
|
||||||
|
opts.subdir orelse "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// First check the env var. On Windows we have to allocate so this tracks
|
// 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.
|
// both whether we have the env var and whether we own it.
|
||||||
// on Windows we treat `LOCALAPPDATA` as a fallback for `XDG_CONFIG_HOME`
|
// on Windows we treat `LOCALAPPDATA` as a fallback for `XDG_CONFIG_HOME`
|
||||||
@ -93,15 +102,6 @@ fn dir(
|
|||||||
return try alloc.dupe(u8, env);
|
return try alloc.dupe(u8, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a cached home dir, use that.
|
|
||||||
if (opts.home) |home| {
|
|
||||||
return try std.fs.path.join(alloc, &[_][]const u8{
|
|
||||||
home,
|
|
||||||
internal_opts.default_subdir,
|
|
||||||
opts.subdir orelse "",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get our home dir
|
// Get our home dir
|
||||||
var buf: [1024]u8 = undefined;
|
var buf: [1024]u8 = undefined;
|
||||||
if (try homedir.home(&buf)) |home| {
|
if (try homedir.home(&buf)) |home| {
|
||||||
|
Reference in New Issue
Block a user