aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-11 22:11:16 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:09 -0800
commit68621afd2e203d82b6f53bf4ede951827fa98db8 (patch)
tree60899decd0062ce7786592e49ca77ab6f80d22fd /src
parent0e230993d51d0ecded40d5235ada4f2f64036b26 (diff)
downloadzig-68621afd2e203d82b6f53bf4ede951827fa98db8.tar.gz
zig-68621afd2e203d82b6f53bf4ede951827fa98db8.zip
std.tar: update fs API calls to take io argument
Diffstat (limited to 'src')
-rw-r--r--src/Builtin.zig3
-rw-r--r--src/Package/Fetch.zig20
-rw-r--r--src/Package/Fetch/git.zig2
-rw-r--r--src/fmt.zig2
4 files changed, 14 insertions, 13 deletions
diff --git a/src/Builtin.zig b/src/Builtin.zig
index b0077f2276..9e4fae8e6a 100644
--- a/src/Builtin.zig
+++ b/src/Builtin.zig
@@ -313,8 +313,9 @@ pub fn updateFileOnDisk(file: *File, comp: *Compilation) !void {
assert(file.source != null);
const root_dir, const sub_path = file.path.openInfo(comp.dirs);
+ const io = comp.io;
- if (root_dir.statFile(sub_path)) |stat| {
+ if (root_dir.statFile(io, sub_path, .{})) |stat| {
if (stat.size != file.source.?.len) {
std.log.warn(
"the cached file '{f}' had the wrong size. Expected {d}, found {d}. " ++
diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig
index 844acf9339..d25ee55c32 100644
--- a/src/Package/Fetch.zig
+++ b/src/Package/Fetch.zig
@@ -1440,13 +1440,13 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void
},
.sym_link => {
var buf: [fs.max_path_bytes]u8 = undefined;
- const link_name = try dir.readLink(entry.path, &buf);
+ const link_name = try dir.readLink(io, entry.path, &buf);
// TODO: if this would create a symlink to outside
// the destination directory, fail with an error instead.
- tmp_dir.symLink(link_name, entry.path, .{}) catch |err| switch (err) {
+ tmp_dir.symLink(io, link_name, entry.path, .{}) catch |err| switch (err) {
error.FileNotFound => {
if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(io, dirname);
- try tmp_dir.symLink(link_name, entry.path, .{});
+ try tmp_dir.symLink(io, link_name, entry.path, .{});
},
else => |e| return e,
};
@@ -1698,7 +1698,7 @@ fn hashFileFallible(io: Io, dir: Io.Dir, hashed_file: *HashedFile) HashedFile.Er
}
},
.link => {
- const link_name = try dir.readLink(hashed_file.fs_path, &buf);
+ const link_name = try dir.readLink(io, hashed_file.fs_path, &buf);
if (fs.path.sep != canonical_sep) {
// Package hashes are intended to be consistent across
// platforms which means we must normalize path separators
@@ -2218,13 +2218,13 @@ test "set executable bit based on file content" {
defer out.close(io);
const S = std.posix.S;
// expect executable bit not set
- try std.testing.expect((try out.statFile("file1")).mode & S.IXUSR == 0);
- try std.testing.expect((try out.statFile("script_without_shebang")).mode & S.IXUSR == 0);
+ try std.testing.expect((try out.statFile(io, "file1", .{})).mode & S.IXUSR == 0);
+ try std.testing.expect((try out.statFile(io, "script_without_shebang", .{})).mode & S.IXUSR == 0);
// expect executable bit set
- try std.testing.expect((try out.statFile("hello")).mode & S.IXUSR != 0);
- try std.testing.expect((try out.statFile("script")).mode & S.IXUSR != 0);
- try std.testing.expect((try out.statFile("script_with_shebang_without_exec_bit")).mode & S.IXUSR != 0);
- try std.testing.expect((try out.statFile("hello_ln")).mode & S.IXUSR != 0);
+ try std.testing.expect((try out.statFile(io, "hello", .{})).mode & S.IXUSR != 0);
+ try std.testing.expect((try out.statFile(io, "script", .{})).mode & S.IXUSR != 0);
+ try std.testing.expect((try out.statFile(io, "script_with_shebang_without_exec_bit", .{})).mode & S.IXUSR != 0);
+ try std.testing.expect((try out.statFile(io, "hello_ln", .{})).mode & S.IXUSR != 0);
//
// $ ls -al zig-cache/tmp/OCz9ovUcstDjTC_U/zig-global-cache/p/1220fecb4c06a9da8673c87fe8810e15785f1699212f01728eadce094d21effeeef3
diff --git a/src/Package/Fetch/git.zig b/src/Package/Fetch/git.zig
index 33ff982b66..255f0e6f69 100644
--- a/src/Package/Fetch/git.zig
+++ b/src/Package/Fetch/git.zig
@@ -281,7 +281,7 @@ pub const Repository = struct {
const symlink_object = try repository.odb.readObject();
if (symlink_object.type != .blob) return error.InvalidFile;
const link_name = symlink_object.data;
- dir.symLink(link_name, entry.name, .{}) catch |e| {
+ dir.symLink(io, link_name, entry.name, .{}) catch |e| {
const file_name = try std.fs.path.join(diagnostics.allocator, &.{ current_path, entry.name });
errdefer diagnostics.allocator.free(file_name);
const link_name_dup = try diagnostics.allocator.dupe(u8, link_name);
diff --git a/src/fmt.zig b/src/fmt.zig
index 1a1e5298e2..59b4470f81 100644
--- a/src/fmt.zig
+++ b/src/fmt.zig
@@ -182,7 +182,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
// Mark any excluded files/directories as already seen,
// so that they are skipped later during actual processing
for (excluded_files.items) |file_path| {
- const stat = Io.Dir.cwd().statFile(file_path) catch |err| switch (err) {
+ const stat = Io.Dir.cwd().statFile(io, file_path, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
// On Windows, statFile does not work for directories
error.IsDir => dir: {