aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-08 14:17:52 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:08 -0800
commit9f4d40b1f9bffc4137055b8a07f042ecfa398124 (patch)
treebe2a20f7e4f0d09a955c654e6627d147836954da /lib/std
parent264d714321d3e5f1f189af393e1fb24d101a7e91 (diff)
downloadzig-9f4d40b1f9bffc4137055b8a07f042ecfa398124.tar.gz
zig-9f4d40b1f9bffc4137055b8a07f042ecfa398124.zip
update all stat() to stat(io)
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Build/Cache.zig9
-rw-r--r--lib/std/Build/WebServer.zig2
-rw-r--r--lib/std/Io/test.zig4
-rw-r--r--lib/std/dynamic_library.zig2
-rw-r--r--lib/std/fs/test.zig22
-rw-r--r--lib/std/os/linux/IoUring.zig6
-rw-r--r--lib/std/os/linux/test.zig4
7 files changed, 25 insertions, 24 deletions
diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig
index fdcb2ab714..0176d71a1c 100644
--- a/lib/std/Build/Cache.zig
+++ b/lib/std/Build/Cache.zig
@@ -775,7 +775,7 @@ pub const Manifest = struct {
};
defer this_file.close(io);
- const actual_stat = this_file.stat() catch |err| {
+ const actual_stat = this_file.stat(io) catch |err| {
self.diagnostic = .{ .file_stat = .{
.file_index = idx,
.err = err,
@@ -883,7 +883,7 @@ pub const Manifest = struct {
defer file.close(io);
// Save locally and also save globally (we still hold the global lock).
- const stat = file.stat() catch |err| switch (err) {
+ const stat = file.stat(io) catch |err| switch (err) {
error.Canceled => return error.Canceled,
else => return true,
};
@@ -909,7 +909,8 @@ pub const Manifest = struct {
}
fn populateFileHashHandle(self: *Manifest, ch_file: *File, handle: Io.File) !void {
- const actual_stat = try handle.stat();
+ const io = self.cache.io;
+ const actual_stat = try handle.stat(io);
ch_file.stat = .{
.size = actual_stat.size,
.mtime = actual_stat.mtime,
@@ -1333,7 +1334,7 @@ fn testGetCurrentFileTimestamp(io: Io, dir: Io.Dir) !Io.Timestamp {
dir.deleteFile(test_out_file) catch {};
}
- return (try file.stat()).mtime;
+ return (try file.stat(io)).mtime;
}
test "cache file and then recall it" {
diff --git a/lib/std/Build/WebServer.zig b/lib/std/Build/WebServer.zig
index 9938d5e1b0..472e87b05a 100644
--- a/lib/std/Build/WebServer.zig
+++ b/lib/std/Build/WebServer.zig
@@ -509,7 +509,7 @@ pub fn serveTarFile(ws: *WebServer, request: *http.Server.Request, paths: []cons
continue;
};
defer file.close(io);
- const stat = try file.stat();
+ const stat = try file.stat(io);
var read_buffer: [1024]u8 = undefined;
var file_reader: Io.File.Reader = .initSize(file, io, &read_buffer, stat.size);
diff --git a/lib/std/Io/test.zig b/lib/std/Io/test.zig
index e731dc18d7..8b9d714ee8 100644
--- a/lib/std/Io/test.zig
+++ b/lib/std/Io/test.zig
@@ -124,13 +124,13 @@ test "updateTimes" {
var file = try tmp.dir.createFile(io, tmp_file_name, .{ .read = true });
defer file.close(io);
- const stat_old = try file.stat();
+ const stat_old = try file.stat(io);
// Set atime and mtime to 5s before
try file.updateTimes(
stat_old.atime.subDuration(.fromSeconds(5)),
stat_old.mtime.subDuration(.fromSeconds(5)),
);
- const stat_new = try file.stat();
+ const stat_new = try file.stat(io);
try expect(stat_new.atime.nanoseconds < stat_old.atime.nanoseconds);
try expect(stat_new.mtime.nanoseconds < stat_old.mtime.nanoseconds);
}
diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig
index b1965b60ee..f02caa1f5b 100644
--- a/lib/std/dynamic_library.zig
+++ b/lib/std/dynamic_library.zig
@@ -226,7 +226,7 @@ pub const ElfDynLib = struct {
defer posix.close(fd);
const file: Io.File = .{ .handle = fd };
- const stat = try file.stat();
+ const stat = try file.stat(io);
const size = std.math.cast(usize, stat.size) orelse return error.FileTooBig;
const page_size = std.heap.pageSize();
diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig
index 9924cafaf8..7b12ba4271 100644
--- a/lib/std/fs/test.zig
+++ b/lib/std/fs/test.zig
@@ -350,7 +350,7 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" {
};
defer symlink.close(io);
- const stat = try symlink.stat();
+ const stat = try symlink.stat(io);
try testing.expectEqual(File.Kind.sym_link, stat.kind);
}
}.impl);
@@ -396,7 +396,7 @@ test "openDirAbsolute" {
var tmp = tmpDir(.{});
defer tmp.cleanup();
- const tmp_ino = (try tmp.dir.stat()).inode;
+ const tmp_ino = (try tmp.dir.stat(io)).inode;
try tmp.dir.makeDir("subdir");
const sub_path = try tmp.dir.realpathAlloc(testing.allocator, "subdir");
@@ -406,7 +406,7 @@ test "openDirAbsolute" {
var tmp_sub = try fs.openDirAbsolute(sub_path, .{});
defer tmp_sub.close(io);
- const sub_ino = (try tmp_sub.stat()).inode;
+ const sub_ino = (try tmp_sub.stat(io)).inode;
{
// Can open sub_path + ".."
@@ -416,7 +416,7 @@ test "openDirAbsolute" {
var dir = try fs.openDirAbsolute(dir_path, .{});
defer dir.close(io);
- const ino = (try dir.stat()).inode;
+ const ino = (try dir.stat(io)).inode;
try testing.expectEqual(tmp_ino, ino);
}
@@ -428,7 +428,7 @@ test "openDirAbsolute" {
var dir = try fs.openDirAbsolute(dir_path, .{});
defer dir.close(io);
- const ino = (try dir.stat()).inode;
+ const ino = (try dir.stat(io)).inode;
try testing.expectEqual(sub_ino, ino);
}
@@ -440,7 +440,7 @@ test "openDirAbsolute" {
var dir = try fs.openDirAbsolute(dir_path, .{});
defer dir.close(io);
- const ino = (try dir.stat()).inode;
+ const ino = (try dir.stat(io)).inode;
try testing.expectEqual(tmp_ino, ino);
}
}
@@ -849,7 +849,7 @@ test "directory operations on files" {
// ensure the file still exists and is a file as a sanity check
file = try ctx.dir.openFile(io, test_file_name, .{});
- const stat = try file.stat();
+ const stat = try file.stat(io);
try testing.expectEqual(File.Kind.file, stat.kind);
file.close(io);
}
@@ -1151,7 +1151,7 @@ test "renameAbsolute" {
// ensure the file was renamed
try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(io, test_file_name, .{}));
file = try tmp_dir.dir.openFile(io, renamed_test_file_name, .{});
- const stat = try file.stat();
+ const stat = try file.stat(io);
try testing.expectEqual(File.Kind.file, stat.kind);
file.close(io);
@@ -2099,17 +2099,17 @@ test "chmod" {
const file = try tmp.dir.createFile(io, "test_file", .{ .mode = 0o600 });
defer file.close(io);
- try testing.expectEqual(@as(File.Mode, 0o600), (try file.stat()).mode & 0o7777);
+ try testing.expectEqual(@as(File.Mode, 0o600), (try file.stat(io)).mode & 0o7777);
try file.chmod(0o644);
- try testing.expectEqual(@as(File.Mode, 0o644), (try file.stat()).mode & 0o7777);
+ try testing.expectEqual(@as(File.Mode, 0o644), (try file.stat(io)).mode & 0o7777);
try tmp.dir.makeDir("test_dir");
var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true });
defer dir.close(io);
try dir.chmod(0o700);
- try testing.expectEqual(@as(File.Mode, 0o700), (try dir.stat()).mode & 0o7777);
+ try testing.expectEqual(@as(File.Mode, 0o700), (try dir.stat(io)).mode & 0o7777);
}
test "chown" {
diff --git a/lib/std/os/linux/IoUring.zig b/lib/std/os/linux/IoUring.zig
index 167c6ef398..3c9a313a4a 100644
--- a/lib/std/os/linux/IoUring.zig
+++ b/lib/std/os/linux/IoUring.zig
@@ -2655,7 +2655,7 @@ test "fallocate" {
const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 });
defer file.close(io);
- try testing.expectEqual(@as(u64, 0), (try file.stat()).size);
+ try testing.expectEqual(@as(u64, 0), (try file.stat(io)).size);
const len: u64 = 65536;
const sqe = try ring.fallocate(0xaaaaaaaa, file.handle, 0, 0, len);
@@ -2681,7 +2681,7 @@ test "fallocate" {
.flags = 0,
}, cqe);
- try testing.expectEqual(len, (try file.stat()).size);
+ try testing.expectEqual(len, (try file.stat(io)).size);
}
test "statx" {
@@ -2702,7 +2702,7 @@ test "statx" {
const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 });
defer file.close(io);
- try testing.expectEqual(@as(u64, 0), (try file.stat()).size);
+ try testing.expectEqual(@as(u64, 0), (try file.stat(io)).size);
try file.writeAll("foobar");
diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig
index d7cfb4e138..cfafebe826 100644
--- a/lib/std/os/linux/test.zig
+++ b/lib/std/os/linux/test.zig
@@ -21,7 +21,7 @@ test "fallocate" {
const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 });
defer file.close(io);
- try expect((try file.stat()).size == 0);
+ try expect((try file.stat(io)).size == 0);
const len: i64 = 65536;
switch (linux.errno(linux.fallocate(file.handle, 0, 0, len))) {
@@ -31,7 +31,7 @@ test "fallocate" {
else => |errno| std.debug.panic("unhandled errno: {}", .{errno}),
}
- try expect((try file.stat()).size == len);
+ try expect((try file.stat(io)).size == len);
}
test "getpid" {