commit 70e19ea3533528b90b4548e162e334f5a8392e64 (tree)
parent 51a6f3a5251096f346eb28b22e1c20ed2ceb7d9e
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sun, 21 Dec 2025 17:17:11 -0800
update more "realpath" callsites
Diffstat:
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
@@ -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,
};
diff --git a/test/standalone/windows_bat_args/test.zig b/test/standalone/windows_bat_args/test.zig
@@ -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, " .. " });
};
diff --git a/test/standalone/windows_spawn/main.zig b/test/standalone/windows_spawn/main.zig
@@ -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);
diff --git a/tools/fetch_them_macos_headers.zig b/tools/fetch_them_macos_headers.zig
@@ -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 });