aboutsummaryrefslogtreecommitdiff
path: root/src/introspect.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-05 19:08:37 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:07 -0800
commitaafddc2ea13e40a8262d9378aeca2e097a37ac03 (patch)
tree46770e51147a635a43c2e7356e62064466b51c34 /src/introspect.zig
parenteab354b2f5d7242c036523394023e9824be7eca9 (diff)
downloadzig-aafddc2ea13e40a8262d9378aeca2e097a37ac03.tar.gz
zig-aafddc2ea13e40a8262d9378aeca2e097a37ac03.zip
update all occurrences of close() to close(io)
Diffstat (limited to 'src/introspect.zig')
-rw-r--r--src/introspect.zig28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/introspect.zig b/src/introspect.zig
index 8467b566c6..9b6797e7d8 100644
--- a/src/introspect.zig
+++ b/src/introspect.zig
@@ -1,18 +1,21 @@
-const std = @import("std");
const builtin = @import("builtin");
+const build_options = @import("build_options");
+
+const std = @import("std");
+const Io = std.Io;
const mem = std.mem;
-const Allocator = mem.Allocator;
+const Allocator = std.mem.Allocator;
const os = std.os;
const fs = std.fs;
const Cache = std.Build.Cache;
+
const Compilation = @import("Compilation.zig");
const Package = @import("Package.zig");
-const build_options = @import("build_options");
/// Returns the sub_path that worked, or `null` if none did.
/// The path of the returned Directory is relative to `base`.
/// The handle of the returned Directory is open.
-fn testZigInstallPrefix(base_dir: fs.Dir) ?Cache.Directory {
+fn testZigInstallPrefix(io: Io, base_dir: Io.Dir) ?Cache.Directory {
const test_index_file = "std" ++ fs.path.sep_str ++ "std.zig";
zig_dir: {
@@ -20,31 +23,31 @@ fn testZigInstallPrefix(base_dir: fs.Dir) ?Cache.Directory {
const lib_zig = "lib" ++ fs.path.sep_str ++ "zig";
var test_zig_dir = base_dir.openDir(lib_zig, .{}) catch break :zig_dir;
const file = test_zig_dir.openFile(test_index_file, .{}) catch {
- test_zig_dir.close();
+ test_zig_dir.close(io);
break :zig_dir;
};
- file.close();
+ file.close(io);
return .{ .handle = test_zig_dir, .path = lib_zig };
}
// Try lib/std/std.zig
var test_zig_dir = base_dir.openDir("lib", .{}) catch return null;
const file = test_zig_dir.openFile(test_index_file, .{}) catch {
- test_zig_dir.close();
+ test_zig_dir.close(io);
return null;
};
- file.close();
+ file.close(io);
return .{ .handle = test_zig_dir, .path = "lib" };
}
/// Both the directory handle and the path are newly allocated resources which the caller now owns.
-pub fn findZigLibDir(gpa: Allocator) !Cache.Directory {
+pub fn findZigLibDir(gpa: Allocator, io: Io) !Cache.Directory {
const cwd_path = try getResolvedCwd(gpa);
defer gpa.free(cwd_path);
const self_exe_path = try fs.selfExePathAlloc(gpa);
defer gpa.free(self_exe_path);
- return findZigLibDirFromSelfExe(gpa, cwd_path, self_exe_path);
+ return findZigLibDirFromSelfExe(gpa, io, cwd_path, self_exe_path);
}
/// Like `std.process.getCwdAlloc`, but also resolves the path with `std.fs.path.resolve`. This
@@ -73,6 +76,7 @@ pub fn getResolvedCwd(gpa: Allocator) error{
/// Both the directory handle and the path are newly allocated resources which the caller now owns.
pub fn findZigLibDirFromSelfExe(
allocator: Allocator,
+ io: Io,
/// The return value of `getResolvedCwd`.
/// Passed as an argument to avoid pointlessly repeating the call.
cwd_path: []const u8,
@@ -82,9 +86,9 @@ pub fn findZigLibDirFromSelfExe(
var cur_path: []const u8 = self_exe_path;
while (fs.path.dirname(cur_path)) |dirname| : (cur_path = dirname) {
var base_dir = cwd.openDir(dirname, .{}) catch continue;
- defer base_dir.close();
+ defer base_dir.close(io);
- const sub_directory = testZigInstallPrefix(base_dir) orelse continue;
+ const sub_directory = testZigInstallPrefix(io, base_dir) orelse continue;
const p = try fs.path.join(allocator, &.{ dirname, sub_directory.path.? });
defer allocator.free(p);