move current expandHome functionality into separate expandHomeUnix function

This commit is contained in:
z-jxy
2024-12-28 21:06:56 -05:00
committed by Mitchell Hashimoto
parent 138a8f1602
commit 5ae2cc01ac
2 changed files with 22 additions and 18 deletions

View File

@@ -4364,26 +4364,21 @@ pub const RepeatablePath = struct {
// Check if the path starts with a tilde and expand it to the home directory on linux/mac
if (std.mem.startsWith(u8, path, "~/")) {
if (try internal_os.expandHome(path, &buf)) |expanded_path| {
log.debug(
"expanding file path from home directory: path={s}",
.{expanded_path},
);
switch (self.value.items[i]) {
.optional, .required => |*p| p.* = try alloc.dupeZ(u8, expanded_path),
}
continue;
} else {
try diags.append(alloc, .{
.message = try std.fmt.allocPrintZ(
alloc,
"error expanding home path {s}",
.{path},
),
});
const expanded: []u8 = try internal_os.expandHome(path, &buf) orelse {
// Blank this path so that we don't attempt to resolve it again
self.value.items[i] = .{ .required = "" };
continue;
};
log.debug(
"expanding file path from home directory: path={s}",
.{expanded},
);
switch (self.value.items[i]) {
.optional, .required => |*p| p.* = try alloc.dupeZ(u8, expanded),
}
continue;
}
const abs = dir.realpath(path, &buf) catch |err| abs: {