authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-08 14:17:52-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:08-08:00
log9f4d40b1f9bffc4137055b8a07f042ecfa398124
treebe2a20f7e4f0d09a955c654e6627d147836954da
parent264d714321d3e5f1f189af393e1fb24d101a7e91

update all stat() to stat(io)


23 files changed, 80 insertions(+), 68 deletions(-)

lib/compiler/objcopy.zig+1-1
......@@ -155,7 +155,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
155155 const input_file = Io.Dir.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err });
156156 defer input_file.close(io);
157157
158 const stat = input_file.stat() catch |err| fatal("failed to stat {s}: {t}", .{ input, err });
158 const stat = input_file.stat(io) catch |err| fatal("failed to stat {s}: {t}", .{ input, err });
159159
160160 var in: File.Reader = .initSize(input_file, io, &input_buffer, stat.size);
161161
lib/compiler/resinator/utils.zig+1-1
......@@ -38,7 +38,7 @@ pub fn openFileNotDir(
3838 errdefer file.close(io);
3939 // https://github.com/ziglang/zig/issues/5732
4040 if (builtin.os.tag != .windows) {
41 const stat = try file.stat();
41 const stat = try file.stat(io);
4242
4343 if (stat.kind == .directory)
4444 return error.IsDir;
lib/compiler/std-docs.zig+1-1
......@@ -227,7 +227,7 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void {
227227 }
228228 var file = try entry.dir.openFile(io, entry.basename, .{});
229229 defer file.close(io);
230 const stat = try file.stat();
230 const stat = try file.stat(io);
231231 var file_reader: std.Io.File.Reader = .{
232232 .file = file,
233233 .interface = std.Io.File.Reader.initInterface(&.{}),
lib/std/Build/Cache.zig+5-4
......@@ -775,7 +775,7 @@ pub const Manifest = struct {
775775 };
776776 defer this_file.close(io);
777777
778 const actual_stat = this_file.stat() catch |err| {
778 const actual_stat = this_file.stat(io) catch |err| {
779779 self.diagnostic = .{ .file_stat = .{
780780 .file_index = idx,
781781 .err = err,
......@@ -883,7 +883,7 @@ pub const Manifest = struct {
883883 defer file.close(io);
884884
885885 // Save locally and also save globally (we still hold the global lock).
886 const stat = file.stat() catch |err| switch (err) {
886 const stat = file.stat(io) catch |err| switch (err) {
887887 error.Canceled => return error.Canceled,
888888 else => return true,
889889 };
......@@ -909,7 +909,8 @@ pub const Manifest = struct {
909909 }
910910
911911 fn populateFileHashHandle(self: *Manifest, ch_file: *File, handle: Io.File) !void {
912 const actual_stat = try handle.stat();
912 const io = self.cache.io;
913 const actual_stat = try handle.stat(io);
913914 ch_file.stat = .{
914915 .size = actual_stat.size,
915916 .mtime = actual_stat.mtime,
......@@ -1333,7 +1334,7 @@ fn testGetCurrentFileTimestamp(io: Io, dir: Io.Dir) !Io.Timestamp {
13331334 dir.deleteFile(test_out_file) catch {};
13341335 }
13351336
1336 return (try file.stat()).mtime;
1337 return (try file.stat(io)).mtime;
13371338}
13381339
13391340test "cache file and then recall it" {
lib/std/Build/WebServer.zig+1-1
......@@ -509,7 +509,7 @@ pub fn serveTarFile(ws: *WebServer, request: *http.Server.Request, paths: []cons
509509 continue;
510510 };
511511 defer file.close(io);
512 const stat = try file.stat();
512 const stat = try file.stat(io);
513513 var read_buffer: [1024]u8 = undefined;
514514 var file_reader: Io.File.Reader = .initSize(file, io, &read_buffer, stat.size);
515515
lib/std/Io/test.zig+2-2
......@@ -124,13 +124,13 @@ test "updateTimes" {
124124 var file = try tmp.dir.createFile(io, tmp_file_name, .{ .read = true });
125125 defer file.close(io);
126126
127 const stat_old = try file.stat();
127 const stat_old = try file.stat(io);
128128 // Set atime and mtime to 5s before
129129 try file.updateTimes(
130130 stat_old.atime.subDuration(.fromSeconds(5)),
131131 stat_old.mtime.subDuration(.fromSeconds(5)),
132132 );
133 const stat_new = try file.stat();
133 const stat_new = try file.stat(io);
134134 try expect(stat_new.atime.nanoseconds < stat_old.atime.nanoseconds);
135135 try expect(stat_new.mtime.nanoseconds < stat_old.mtime.nanoseconds);
136136}
lib/std/dynamic_library.zig+1-1
......@@ -226,7 +226,7 @@ pub const ElfDynLib = struct {
226226 defer posix.close(fd);
227227
228228 const file: Io.File = .{ .handle = fd };
229 const stat = try file.stat();
229 const stat = try file.stat(io);
230230 const size = std.math.cast(usize, stat.size) orelse return error.FileTooBig;
231231
232232 const page_size = std.heap.pageSize();
lib/std/fs/test.zig+11-11
......@@ -350,7 +350,7 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" {
350350 };
351351 defer symlink.close(io);
352352
353 const stat = try symlink.stat();
353 const stat = try symlink.stat(io);
354354 try testing.expectEqual(File.Kind.sym_link, stat.kind);
355355 }
356356 }.impl);
......@@ -396,7 +396,7 @@ test "openDirAbsolute" {
396396 var tmp = tmpDir(.{});
397397 defer tmp.cleanup();
398398
399 const tmp_ino = (try tmp.dir.stat()).inode;
399 const tmp_ino = (try tmp.dir.stat(io)).inode;
400400
401401 try tmp.dir.makeDir("subdir");
402402 const sub_path = try tmp.dir.realpathAlloc(testing.allocator, "subdir");
......@@ -406,7 +406,7 @@ test "openDirAbsolute" {
406406 var tmp_sub = try fs.openDirAbsolute(sub_path, .{});
407407 defer tmp_sub.close(io);
408408
409 const sub_ino = (try tmp_sub.stat()).inode;
409 const sub_ino = (try tmp_sub.stat(io)).inode;
410410
411411 {
412412 // Can open sub_path + ".."
......@@ -416,7 +416,7 @@ test "openDirAbsolute" {
416416 var dir = try fs.openDirAbsolute(dir_path, .{});
417417 defer dir.close(io);
418418
419 const ino = (try dir.stat()).inode;
419 const ino = (try dir.stat(io)).inode;
420420 try testing.expectEqual(tmp_ino, ino);
421421 }
422422
......@@ -428,7 +428,7 @@ test "openDirAbsolute" {
428428 var dir = try fs.openDirAbsolute(dir_path, .{});
429429 defer dir.close(io);
430430
431 const ino = (try dir.stat()).inode;
431 const ino = (try dir.stat(io)).inode;
432432 try testing.expectEqual(sub_ino, ino);
433433 }
434434
......@@ -440,7 +440,7 @@ test "openDirAbsolute" {
440440 var dir = try fs.openDirAbsolute(dir_path, .{});
441441 defer dir.close(io);
442442
443 const ino = (try dir.stat()).inode;
443 const ino = (try dir.stat(io)).inode;
444444 try testing.expectEqual(tmp_ino, ino);
445445 }
446446}
......@@ -849,7 +849,7 @@ test "directory operations on files" {
849849
850850 // ensure the file still exists and is a file as a sanity check
851851 file = try ctx.dir.openFile(io, test_file_name, .{});
852 const stat = try file.stat();
852 const stat = try file.stat(io);
853853 try testing.expectEqual(File.Kind.file, stat.kind);
854854 file.close(io);
855855 }
......@@ -1151,7 +1151,7 @@ test "renameAbsolute" {
11511151 // ensure the file was renamed
11521152 try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(io, test_file_name, .{}));
11531153 file = try tmp_dir.dir.openFile(io, renamed_test_file_name, .{});
1154 const stat = try file.stat();
1154 const stat = try file.stat(io);
11551155 try testing.expectEqual(File.Kind.file, stat.kind);
11561156 file.close(io);
11571157
......@@ -2099,17 +2099,17 @@ test "chmod" {
20992099
21002100 const file = try tmp.dir.createFile(io, "test_file", .{ .mode = 0o600 });
21012101 defer file.close(io);
2102 try testing.expectEqual(@as(File.Mode, 0o600), (try file.stat()).mode & 0o7777);
2102 try testing.expectEqual(@as(File.Mode, 0o600), (try file.stat(io)).mode & 0o7777);
21032103
21042104 try file.chmod(0o644);
2105 try testing.expectEqual(@as(File.Mode, 0o644), (try file.stat()).mode & 0o7777);
2105 try testing.expectEqual(@as(File.Mode, 0o644), (try file.stat(io)).mode & 0o7777);
21062106
21072107 try tmp.dir.makeDir("test_dir");
21082108 var dir = try tmp.dir.openDir(io, "test_dir", .{ .iterate = true });
21092109 defer dir.close(io);
21102110
21112111 try dir.chmod(0o700);
2112 try testing.expectEqual(@as(File.Mode, 0o700), (try dir.stat()).mode & 0o7777);
2112 try testing.expectEqual(@as(File.Mode, 0o700), (try dir.stat(io)).mode & 0o7777);
21132113}
21142114
21152115test "chown" {
lib/std/os/linux/IoUring.zig+3-3
......@@ -2655,7 +2655,7 @@ test "fallocate" {
26552655 const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 });
26562656 defer file.close(io);
26572657
2658 try testing.expectEqual(@as(u64, 0), (try file.stat()).size);
2658 try testing.expectEqual(@as(u64, 0), (try file.stat(io)).size);
26592659
26602660 const len: u64 = 65536;
26612661 const sqe = try ring.fallocate(0xaaaaaaaa, file.handle, 0, 0, len);
......@@ -2681,7 +2681,7 @@ test "fallocate" {
26812681 .flags = 0,
26822682 }, cqe);
26832683
2684 try testing.expectEqual(len, (try file.stat()).size);
2684 try testing.expectEqual(len, (try file.stat(io)).size);
26852685}
26862686
26872687test "statx" {
......@@ -2702,7 +2702,7 @@ test "statx" {
27022702 const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 });
27032703 defer file.close(io);
27042704
2705 try testing.expectEqual(@as(u64, 0), (try file.stat()).size);
2705 try testing.expectEqual(@as(u64, 0), (try file.stat(io)).size);
27062706
27072707 try file.writeAll("foobar");
27082708
lib/std/os/linux/test.zig+2-2
......@@ -21,7 +21,7 @@ test "fallocate" {
2121 const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 });
2222 defer file.close(io);
2323
24 try expect((try file.stat()).size == 0);
24 try expect((try file.stat(io)).size == 0);
2525
2626 const len: i64 = 65536;
2727 switch (linux.errno(linux.fallocate(file.handle, 0, 0, len))) {
......@@ -31,7 +31,7 @@ test "fallocate" {
3131 else => |errno| std.debug.panic("unhandled errno: {}", .{errno}),
3232 }
3333
34 try expect((try file.stat()).size == len);
34 try expect((try file.stat(io)).size == len);
3535}
3636
3737test "getpid" {
src/Compilation.zig+1-1
......@@ -5367,7 +5367,7 @@ fn docsCopyModule(
53675367 });
53685368 };
53695369 defer file.close(io);
5370 const stat = try file.stat();
5370 const stat = try file.stat(io);
53715371 var file_reader: Io.File.Reader = .initSize(file, io, &buffer, stat.size);
53725372
53735373 archiver.writeFileTimestamp(entry.path, &file_reader, stat.mtime) catch |err| {
src/Zcu.zig+1-1
......@@ -1080,7 +1080,7 @@ pub const File = struct {
10801080 };
10811081 defer f.close(io);
10821082
1083 const stat = f.stat() catch |err| switch (err) {
1083 const stat = f.stat(io) catch |err| switch (err) {
10841084 error.Streaming => {
10851085 // Since `file.stat` is populated, this was previously a file stream; since it is
10861086 // now not a file stream, it must have changed.
src/Zcu/PerThread.zig+2-2
......@@ -98,7 +98,7 @@ pub fn updateFile(
9898 };
9999 defer source_file.close(io);
100100
101 const stat = try source_file.stat();
101 const stat = try source_file.stat(io);
102102
103103 const want_local_cache = switch (file.path.root) {
104104 .none, .local_cache => true,
......@@ -2470,7 +2470,7 @@ fn updateEmbedFileInner(
24702470 };
24712471 defer file.close(io);
24722472
2473 const stat: Cache.File.Stat = .fromFs(try file.stat());
2473 const stat: Cache.File.Stat = .fromFs(try file.stat(io));
24742474
24752475 if (ef.val != .none) {
24762476 const old_stat = ef.stat;
src/fmt.zig+3-3
......@@ -188,7 +188,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
188188 error.IsDir => dir: {
189189 var dir = try Io.Dir.cwd().openDir(io, file_path, .{});
190190 defer dir.close(io);
191 break :dir try dir.stat();
191 break :dir try dir.stat(io);
192192 },
193193 else => |e| return e,
194194 };
......@@ -227,7 +227,7 @@ fn fmtPathDir(
227227 var dir = try parent_dir.openDir(io, parent_sub_path, .{ .iterate = true });
228228 defer dir.close(io);
229229
230 const stat = try dir.stat();
230 const stat = try dir.stat(io);
231231 if (try fmt.seen.fetchPut(stat.inode, {})) |_| return;
232232
233233 var dir_it = dir.iterate();
......@@ -266,7 +266,7 @@ fn fmtPathFile(
266266 var file_closed = false;
267267 errdefer if (!file_closed) source_file.close(io);
268268
269 const stat = try source_file.stat();
269 const stat = try source_file.stat(io);
270270
271271 if (stat.kind == .directory)
272272 return error.IsDir;
src/link.zig+3-3
......@@ -1112,10 +1112,10 @@ pub const File = struct {
11121112
11131113 fn loadGnuLdScript(base: *File, path: Path, parent_query: UnresolvedInput.Query, file: Io.File) anyerror!void {
11141114 const comp = base.comp;
1115 const io = comp.io;
11151116 const diags = &comp.link_diags;
11161117 const gpa = comp.gpa;
1117 const io = comp.io;
1118 const stat = try file.stat();
1118 const stat = try file.stat(io);
11191119 const size = std.math.cast(u32, stat.size) orelse return error.FileTooBig;
11201120 const buf = try gpa.alloc(u8, size);
11211121 defer gpa.free(buf);
......@@ -2180,7 +2180,7 @@ fn resolvePathInputLib(
21802180 // Appears to be an ELF or archive file.
21812181 return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, pq.query);
21822182 }
2183 const stat = file.stat() catch |err|
2183 const stat = file.stat(io) catch |err|
21842184 fatal("failed to stat {f}: {s}", .{ test_path, @errorName(err) });
21852185 const size = std.math.cast(u32, stat.size) orelse
21862186 fatal("{f}: linker script too big", .{test_path});
src/link/Elf.zig+3-2
......@@ -742,7 +742,7 @@ pub fn loadInput(self: *Elf, input: link.Input) !void {
742742 .dso_exact => @panic("TODO"),
743743 .object => |obj| try parseObject(self, obj),
744744 .archive => |obj| try parseArchive(gpa, diags, &self.file_handles, &self.files, target, debug_fmt_strip, default_sym_version, &self.objects, obj, is_static_lib),
745 .dso => |dso| try parseDso(gpa, diags, dso, &self.shared_objects, &self.files, target),
745 .dso => |dso| try parseDso(gpa, io, diags, dso, &self.shared_objects, &self.files, target),
746746 }
747747}
748748
......@@ -1136,6 +1136,7 @@ fn parseArchive(
11361136
11371137fn parseDso(
11381138 gpa: Allocator,
1139 io: Io,
11391140 diags: *Diags,
11401141 dso: link.Input.Dso,
11411142 shared_objects: *std.StringArrayHashMapUnmanaged(File.Index),
......@@ -1147,7 +1148,7 @@ fn parseDso(
11471148
11481149 const handle = dso.file;
11491150
1150 const stat = Stat.fromFs(try handle.stat());
1151 const stat = Stat.fromFs(try handle.stat(io));
11511152 var header = try SharedObject.parseHeader(gpa, diags, dso.path, handle, stat, target);
11521153 defer header.deinit(gpa);
11531154
src/link/Elf/Archive.zig+24-21
......@@ -1,3 +1,21 @@
1const Archive = @This();
2
3const std = @import("std");
4const Io = std.Io;
5const assert = std.debug.assert;
6const elf = std.elf;
7const fs = std.fs;
8const log = std.log.scoped(.link);
9const mem = std.mem;
10const Path = std.Build.Cache.Path;
11const Allocator = std.mem.Allocator;
12
13const Diags = @import("../../link.zig").Diags;
14const Elf = @import("../Elf.zig");
15const File = @import("file.zig").File;
16const Object = @import("Object.zig");
17const StringTable = @import("../StringTable.zig");
18
119objects: []const Object,
220/// '\n'-delimited
321strtab: []const u8,
......@@ -10,6 +28,7 @@ pub fn deinit(a: *Archive, gpa: Allocator) void {
1028
1129pub fn parse(
1230 gpa: Allocator,
31 io: Io,
1332 diags: *Diags,
1433 file_handles: *const std.ArrayList(File.Handle),
1534 path: Path,
......@@ -25,7 +44,7 @@ pub fn parse(
2544 pos += magic_buffer.len;
2645 }
2746
28 const size = (try handle.stat()).size;
47 const size = (try handle.stat(io)).size;
2948
3049 var objects: std.ArrayList(Object) = .empty;
3150 defer objects.deinit(gpa);
......@@ -120,7 +139,7 @@ pub fn setArHdr(opts: struct {
120139 @memset(mem.asBytes(&hdr), 0x20);
121140
122141 {
123 var writer: std.Io.Writer = .fixed(&hdr.ar_name);
142 var writer: Io.Writer = .fixed(&hdr.ar_name);
124143 switch (opts.name) {
125144 .symtab => writer.print("{s}", .{elf.SYM64NAME}) catch unreachable,
126145 .strtab => writer.print("//", .{}) catch unreachable,
......@@ -133,7 +152,7 @@ pub fn setArHdr(opts: struct {
133152 hdr.ar_gid[0] = '0';
134153 hdr.ar_mode[0] = '0';
135154 {
136 var writer: std.Io.Writer = .fixed(&hdr.ar_size);
155 var writer: Io.Writer = .fixed(&hdr.ar_size);
137156 writer.print("{d}", .{opts.size}) catch unreachable;
138157 }
139158 hdr.ar_fmag = elf.ARFMAG.*;
......@@ -206,7 +225,7 @@ pub const ArSymtab = struct {
206225 ar: ArSymtab,
207226 elf_file: *Elf,
208227
209 fn default(f: Format, writer: *std.Io.Writer) std.Io.Writer.Error!void {
228 fn default(f: Format, writer: *Io.Writer) Io.Writer.Error!void {
210229 const ar = f.ar;
211230 const elf_file = f.elf_file;
212231 for (ar.symtab.items, 0..) |entry, i| {
......@@ -261,7 +280,7 @@ pub const ArStrtab = struct {
261280 try writer.writeAll(ar.buffer.items);
262281 }
263282
264 pub fn format(ar: ArStrtab, writer: *std.Io.Writer) std.Io.Writer.Error!void {
283 pub fn format(ar: ArStrtab, writer: *Io.Writer) Io.Writer.Error!void {
265284 try writer.print("{f}", .{std.ascii.hexEscape(ar.buffer.items, .lower)});
266285 }
267286};
......@@ -277,19 +296,3 @@ pub const ArState = struct {
277296 /// Total size of the contributing object (excludes ar_hdr).
278297 size: u64 = 0,
279298};
280
281const std = @import("std");
282const assert = std.debug.assert;
283const elf = std.elf;
284const fs = std.fs;
285const log = std.log.scoped(.link);
286const mem = std.mem;
287const Path = std.Build.Cache.Path;
288const Allocator = std.mem.Allocator;
289
290const Diags = @import("../../link.zig").Diags;
291const Archive = @This();
292const Elf = @import("../Elf.zig");
293const File = @import("file.zig").File;
294const Object = @import("Object.zig");
295const StringTable = @import("../StringTable.zig");
src/link/Elf/Object.zig+5-2
......@@ -122,13 +122,14 @@ pub fn parse(
122122pub fn parseCommon(
123123 self: *Object,
124124 gpa: Allocator,
125 io: Io,
125126 diags: *Diags,
126127 path: Path,
127128 handle: Io.File,
128129 target: *const std.Target,
129130) !void {
130131 const offset = if (self.archive) |ar| ar.offset else 0;
131 const file_size = (try handle.stat()).size;
132 const file_size = (try handle.stat(io)).size;
132133
133134 const header_buffer = try Elf.preadAllAlloc(gpa, handle, offset, @sizeOf(elf.Elf64_Ehdr));
134135 defer gpa.free(header_buffer);
......@@ -1122,9 +1123,11 @@ pub fn updateArSymtab(self: Object, ar_symtab: *Archive.ArSymtab, elf_file: *Elf
11221123}
11231124
11241125pub fn updateArSize(self: *Object, elf_file: *Elf) !void {
1126 const comp = elf_file.base.comp;
1127 const io = comp.io;
11251128 self.output_ar_state.size = if (self.archive) |ar| ar.size else size: {
11261129 const handle = elf_file.fileHandle(self.file_handle);
1127 break :size (try handle.stat()).size;
1130 break :size (try handle.stat(io)).size;
11281131 };
11291132}
11301133
src/link/MachO.zig+2-1
......@@ -925,6 +925,7 @@ fn addObject(self: *MachO, path: Path, handle_index: File.HandleIndex, offset: u
925925
926926 const comp = self.base.comp;
927927 const gpa = comp.gpa;
928 const io = comp.io;
928929
929930 const abs_path = try std.fs.path.resolvePosix(gpa, &.{
930931 comp.dirs.cwd,
......@@ -934,7 +935,7 @@ fn addObject(self: *MachO, path: Path, handle_index: File.HandleIndex, offset: u
934935 errdefer gpa.free(abs_path);
935936
936937 const file = self.getFileHandle(handle_index);
937 const stat = try file.stat();
938 const stat = try file.stat(io);
938939 const mtime = stat.mtime.toSeconds();
939940 const index: File.Index = @intCast(try self.files.addOne(gpa));
940941 self.files.set(index, .{ .object = .{
src/link/MachO/Archive.zig+2-1
......@@ -6,6 +6,7 @@ pub fn deinit(self: *Archive, allocator: Allocator) void {
66
77pub fn unpack(self: *Archive, macho_file: *MachO, path: Path, handle_index: File.HandleIndex, fat_arch: ?fat.Arch) !void {
88 const comp = macho_file.base.comp;
9 const io = comp.io;
910 const gpa = comp.gpa;
1011 const diags = &comp.link_diags;
1112
......@@ -14,7 +15,7 @@ pub fn unpack(self: *Archive, macho_file: *MachO, path: Path, handle_index: File
1415
1516 const handle = macho_file.getFileHandle(handle_index);
1617 const offset = if (fat_arch) |ar| ar.offset else 0;
17 const end_pos = if (fat_arch) |ar| offset + ar.size else (try handle.stat()).size;
18 const end_pos = if (fat_arch) |ar| offset + ar.size else (try handle.stat(io)).size;
1819
1920 var pos: usize = offset + SARMAG;
2021 while (true) {
src/link/MachO/Object.zig+3-1
......@@ -1689,9 +1689,11 @@ pub fn updateArSymtab(self: Object, ar_symtab: *Archive.ArSymtab, macho_file: *M
16891689}
16901690
16911691pub fn updateArSize(self: *Object, macho_file: *MachO) !void {
1692 const comp = macho_file.base.comp;
1693 const io = comp.io;
16921694 self.output_ar_state.size = if (self.in_archive) |ar| ar.size else size: {
16931695 const file = macho_file.getFileHandle(self.file_handle);
1694 break :size (try file.stat()).size;
1696 break :size (try file.stat(io)).size;
16951697 };
16961698}
16971699
src/link/MachO/relocatable.zig+1-1
......@@ -22,7 +22,7 @@ pub fn flushObject(macho_file: *MachO, comp: *Compilation, module_obj_path: ?Pat
2222 const path = positionals.items[0].path().?;
2323 const in_file = path.root_dir.handle.openFile(io, path.sub_path, .{}) catch |err|
2424 return diags.fail("failed to open {f}: {s}", .{ path, @errorName(err) });
25 const stat = in_file.stat() catch |err|
25 const stat = in_file.stat(io) catch |err|
2626 return diags.fail("failed to stat {f}: {s}", .{ path, @errorName(err) });
2727 const amt = in_file.copyRangeAll(0, macho_file.base.file.?, 0, stat.size) catch |err|
2828 return diags.fail("failed to copy range of file {f}: {s}", .{ path, @errorName(err) });
src/link/tapi.zig+2-2
......@@ -139,9 +139,9 @@ pub const LibStub = struct {
139139 /// Typed contents of the tbd file.
140140 inner: []Tbd,
141141
142 pub fn loadFromFile(allocator: Allocator, file: Io.File) TapiError!LibStub {
142 pub fn loadFromFile(allocator: Allocator, io: Io, file: Io.File) TapiError!LibStub {
143143 const filesize = blk: {
144 const stat = file.stat() catch break :blk std.math.maxInt(u32);
144 const stat = file.stat(io) catch break :blk std.math.maxInt(u32);
145145 break :blk @min(stat.size, std.math.maxInt(u32));
146146 };
147147 const source = try allocator.alloc(u8, filesize);