update more "realpath" callsites

This commit is contained in:
Andrew Kelley
2025-12-21 17:17:11 -08:00
parent 51a6f3a525
commit 70e19ea353
4 changed files with 13 additions and 6 deletions
+9 -2
View File
@@ -1762,7 +1762,10 @@ fn supportedWindowsProgramExtension(ext: []const u8) bool {
}
fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
if (fs.realpathAlloc(b.allocator, full_path)) |p| {
const io = b.graph.io;
const arena = b.allocator;
if (Io.Dir.realPathFileAbsoluteAlloc(io, full_path, arena)) |p| {
return p;
} else |err| switch (err) {
error.OutOfMemory => @panic("OOM"),
@@ -1776,7 +1779,11 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
while (it.next()) |ext| {
if (!supportedWindowsProgramExtension(ext)) continue;
return fs.realPathFileAlloc(b.graph.io, b.fmt("{s}{s}", .{ full_path, ext }), b.allocator) catch |err| switch (err) {
return Io.Dir.realPathFileAbsoluteAlloc(
io,
b.fmt("{s}{s}", .{ full_path, ext }),
arena,
) catch |err| switch (err) {
error.OutOfMemory => @panic("OOM"),
else => continue,
};
+1 -1
View File
@@ -101,7 +101,7 @@ pub fn main() anyerror!void {
// operable program or batch file.
try std.testing.expectError(error.FileNotFound, testExecBat(gpa, "args1.bat .. ", &.{"abc"}, null));
const absolute_with_trailing = blk: {
const absolute_path = try std.fs.realpathAlloc(gpa, "args1.bat");
const absolute_path = try Io.Dir.realPathFileAbsoluteAlloc(io, "args1.bat", gpa);
defer gpa.free(absolute_path);
break :blk try std.mem.concat(gpa, u8, &.{ absolute_path, " .. " });
};
+2 -2
View File
@@ -22,11 +22,11 @@ pub fn main() anyerror!void {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
const tmp_absolute_path = try tmp.dir.realpathAlloc(gpa, ".");
const tmp_absolute_path = try tmp.dir.realPathFileAlloc(io, ".", gpa);
defer gpa.free(tmp_absolute_path);
const tmp_absolute_path_w = try std.unicode.utf8ToUtf16LeAllocZ(gpa, tmp_absolute_path);
defer gpa.free(tmp_absolute_path_w);
const cwd_absolute_path = try Io.Dir.cwd().realpathAlloc(gpa, ".");
const cwd_absolute_path = try Io.Dir.cwd().realPathFileAlloc(io, ".", gpa);
defer gpa.free(cwd_absolute_path);
const tmp_relative_path = try std.fs.path.relative(gpa, cwd_absolute_path, tmp_absolute_path);
defer gpa.free(tmp_relative_path);
+1 -1
View File
@@ -134,7 +134,7 @@ fn fetchTarget(
) !void {
const tmp_filename = "macos-headers";
const headers_list_filename = "macos-headers.o.d";
const tmp_path = try tmp.dir.realpathAlloc(arena, ".");
const tmp_path = try tmp.dir.realPathFileAlloc(io, ".", arena);
const tmp_file_path = try Dir.path.join(arena, &[_][]const u8{ tmp_path, tmp_filename });
const headers_list_path = try Dir.path.join(arena, &[_][]const u8{ tmp_path, headers_list_filename });