authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-08 17:21:52-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:08-08:00
log4218344dd3178f2fd3d9d00e9ff6895ee344df6d
tree38a1378b45349bcd182f6bdb721dadb275c1d02e
parent950d18ef695bb7a28397e080dc3c201559ec4ee2

std.Build.Cache: remove readSmallFile and writeSmallFile

These were to support optimizations involving detecting when to avoid calling into LLD, which are no longer implemented.

18 files changed, 63 insertions(+), 75 deletions(-)

lib/compiler/build_runner.zig+1-1
......@@ -459,7 +459,7 @@ pub fn main() !void {
459459 }
460460 const s = std.fs.path.sep_str;
461461 const tmp_sub_path = "tmp" ++ s ++ (output_tmp_nonce orelse fatal("missing -Z arg", .{}));
462 local_cache_directory.handle.writeFile(.{
462 local_cache_directory.handle.writeFile(io, .{
463463 .sub_path = tmp_sub_path,
464464 .data = buffer.items,
465465 .flags = .{ .exclusive = true },
lib/compiler/reduce.zig+8-4
......@@ -55,6 +55,10 @@ pub fn main() !void {
5555 var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;
5656 const gpa = general_purpose_allocator.allocator();
5757
58 var threaded: std.Io.Threaded = .init(gpa);
59 defer threaded.deinit();
60 const io = threaded.io();
61
5862 const args = try std.process.argsAlloc(arena);
5963
6064 var opt_checker_path: ?[]const u8 = null;
......@@ -233,12 +237,12 @@ pub fn main() !void {
233237 }
234238 }
235239
236 try Io.Dir.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() });
240 try Io.Dir.cwd().writeFile(io, .{ .sub_path = root_source_file_path, .data = rendered.written() });
237241 // std.debug.print("trying this code:\n{s}\n", .{rendered.items});
238242
239243 const interestingness = try runCheck(arena, interestingness_argv.items);
240 std.debug.print("{d} random transformations: {s}. {d}/{d}\n", .{
241 subset_size, @tagName(interestingness), start_index, transformations.items.len,
244 std.debug.print("{d} random transformations: {t}. {d}/{d}\n", .{
245 subset_size, interestingness, start_index, transformations.items.len,
242246 });
243247 switch (interestingness) {
244248 .interesting => {
......@@ -274,7 +278,7 @@ pub fn main() !void {
274278 fixups.clearRetainingCapacity();
275279 rendered.clearRetainingCapacity();
276280 try tree.render(gpa, &rendered.writer, fixups);
277 try Io.Dir.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() });
281 try Io.Dir.cwd().writeFile(io, .{ .sub_path = root_source_file_path, .data = rendered.written() });
278282
279283 return std.process.cleanExit();
280284 }
lib/compiler/resinator/main.zig+1-1
......@@ -212,7 +212,7 @@ pub fn main() !void {
212212 try output_file.writeAll(full_input);
213213 },
214214 .filename => |output_filename| {
215 try Io.Dir.cwd().writeFile(.{ .sub_path = output_filename, .data = full_input });
215 try Io.Dir.cwd().writeFile(io, .{ .sub_path = output_filename, .data = full_input });
216216 },
217217 }
218218 return;
lib/compiler/std-docs.zig+1-1
......@@ -233,7 +233,7 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void {
233233 .interface = std.Io.File.Reader.initInterface(&.{}),
234234 .size = stat.size,
235235 };
236 try archiver.writeFile(entry.path, &file_reader, stat.mtime);
236 try archiver.writeFile(io, entry.path, &file_reader, stat.mtime);
237237 }
238238
239239 {
lib/std/Build/Cache.zig+6-30
......@@ -1276,30 +1276,6 @@ pub const Manifest = struct {
12761276 }
12771277};
12781278
1279/// On operating systems that support symlinks, does a readlink. On other operating systems,
1280/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
1281/// it is treated as not supporting symlinks.
1282pub fn readSmallFile(dir: Io.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {
1283 if (builtin.os.tag == .windows) {
1284 return dir.readFile(sub_path, buffer);
1285 } else {
1286 return dir.readLink(sub_path, buffer);
1287 }
1288}
1289
1290/// On operating systems that support symlinks, does a symlink. On other operating systems,
1291/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
1292/// it is treated as not supporting symlinks.
1293/// `data` must be a valid UTF-8 encoded file path and 255 bytes or fewer.
1294pub fn writeSmallFile(dir: Io.Dir, sub_path: []const u8, data: []const u8) !void {
1295 assert(data.len <= 255);
1296 if (builtin.os.tag == .windows) {
1297 return dir.writeFile(.{ .sub_path = sub_path, .data = data });
1298 } else {
1299 return dir.symLink(data, sub_path, .{});
1300 }
1301}
1302
13031279fn hashFile(io: Io, file: Io.File, bin_digest: *[Hasher.mac_length]u8) Io.File.ReadPositionalError!void {
13041280 var buffer: [2048]u8 = undefined;
13051281 var hasher = hasher_init;
......@@ -1338,7 +1314,7 @@ test "cache file and then recall it" {
13381314 const temp_file = "test.txt";
13391315 const temp_manifest_dir = "temp_manifest_dir";
13401316
1341 try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = "Hello, world!\n" });
1317 try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = "Hello, world!\n" });
13421318
13431319 // Wait for file timestamps to tick
13441320 const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir);
......@@ -1404,7 +1380,7 @@ test "check that changing a file makes cache fail" {
14041380 const original_temp_file_contents = "Hello, world!\n";
14051381 const updated_temp_file_contents = "Hello, world; but updated!\n";
14061382
1407 try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = original_temp_file_contents });
1383 try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = original_temp_file_contents });
14081384
14091385 // Wait for file timestamps to tick
14101386 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
......@@ -1441,7 +1417,7 @@ test "check that changing a file makes cache fail" {
14411417 try ch.writeManifest();
14421418 }
14431419
1444 try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = updated_temp_file_contents });
1420 try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = updated_temp_file_contents });
14451421
14461422 {
14471423 var ch = cache.obtain();
......@@ -1521,8 +1497,8 @@ test "Manifest with files added after initial hash work" {
15211497 const temp_file2 = "cache_hash_post_file_test2.txt";
15221498 const temp_manifest_dir = "cache_hash_post_file_manifest_dir";
15231499
1524 try tmp.dir.writeFile(.{ .sub_path = temp_file1, .data = "Hello, world!\n" });
1525 try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
1500 try tmp.dir.writeFile(io, .{ .sub_path = temp_file1, .data = "Hello, world!\n" });
1501 try tmp.dir.writeFile(io, .{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
15261502
15271503 // Wait for file timestamps to tick
15281504 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
......@@ -1573,7 +1549,7 @@ test "Manifest with files added after initial hash work" {
15731549 try testing.expect(mem.eql(u8, &digest1, &digest2));
15741550
15751551 // Modify the file added after initial hash
1576 try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
1552 try tmp.dir.writeFile(io, .{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
15771553
15781554 // Wait for file timestamps to tick
15791555 const initial_time2 = try testGetCurrentFileTimestamp(tmp.dir);
lib/std/Build/Step/ConfigHeader.zig+1-1
......@@ -264,7 +264,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
264264 });
265265 };
266266
267 b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = output }) catch |err| {
267 b.cache_root.handle.writeFile(io, .{ .sub_path = sub_path, .data = output }) catch |err| {
268268 return step.fail("unable to write file '{f}{s}': {s}", .{
269269 b.cache_root, sub_path, @errorName(err),
270270 });
lib/std/Build/Step/Run.zig+1-1
......@@ -1482,7 +1482,7 @@ fn runCommand(
14821482 .leading => mem.trimStart(u8, stream.bytes.?, &std.ascii.whitespace),
14831483 .trailing => mem.trimEnd(u8, stream.bytes.?, &std.ascii.whitespace),
14841484 };
1485 b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = data }) catch |err| {
1485 b.cache_root.handle.writeFile(io, .{ .sub_path = sub_path, .data = data }) catch |err| {
14861486 return step.fail("unable to write file '{f}{s}': {s}", .{
14871487 b.cache_root, sub_path, @errorName(err),
14881488 });
lib/std/Build/Step/UpdateSourceFiles.zig+1-1
......@@ -84,7 +84,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
8484 }
8585 switch (output_source_file.contents) {
8686 .bytes => |bytes| {
87 b.build_root.handle.writeFile(.{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
87 b.build_root.handle.writeFile(io, .{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
8888 return step.fail("unable to write file '{f}{s}': {t}", .{
8989 b.build_root, output_source_file.sub_path, err,
9090 });
lib/std/Build/Step/WriteFile.zig+1-1
......@@ -273,7 +273,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
273273 }
274274 switch (file.contents) {
275275 .bytes => |bytes| {
276 cache_dir.writeFile(.{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
276 cache_dir.writeFile(io, .{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
277277 return step.fail("unable to write file '{f}{s}{c}{s}': {t}", .{
278278 b.cache_root, cache_path, fs.path.sep, file.sub_path, err,
279279 });
lib/std/Build/WebServer.zig+1-1
......@@ -523,7 +523,7 @@ pub fn serveTarFile(ws: *WebServer, request: *http.Server.Request, paths: []cons
523523 if (cached_cwd_path == null) cached_cwd_path = try std.process.getCwdAlloc(gpa);
524524 break :cwd cached_cwd_path.?;
525525 };
526 try archiver.writeFile(path.sub_path, &file_reader, @intCast(stat.mtime.toSeconds()));
526 try archiver.writeFile(io, path.sub_path, &file_reader, @intCast(stat.mtime.toSeconds()));
527527 }
528528
529529 // intentionally not calling `archiver.finishPedantically`
lib/std/debug.zig+2-2
......@@ -1243,7 +1243,7 @@ test printLineFromFile {
12431243 {
12441244 const path = try join(gpa, &.{ test_dir_path, "one_line.zig" });
12451245 defer gpa.free(path);
1246 try test_dir.dir.writeFile(.{ .sub_path = "one_line.zig", .data = "no new lines in this file, but one is printed anyway" });
1246 try test_dir.dir.writeFile(io, .{ .sub_path = "one_line.zig", .data = "no new lines in this file, but one is printed anyway" });
12471247
12481248 try expectError(error.EndOfFile, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
12491249
......@@ -1254,7 +1254,7 @@ test printLineFromFile {
12541254 {
12551255 const path = try fs.path.join(gpa, &.{ test_dir_path, "three_lines.zig" });
12561256 defer gpa.free(path);
1257 try test_dir.dir.writeFile(.{
1257 try test_dir.dir.writeFile(io, .{
12581258 .sub_path = "three_lines.zig",
12591259 .data =
12601260 \\1
lib/std/fs/test.zig+28-20
......@@ -184,7 +184,7 @@ test "Dir.readLink" {
184184 fn impl(ctx: *TestContext) !void {
185185 // Create some targets
186186 const file_target_path = try ctx.transformPath("file.txt");
187 try ctx.dir.writeFile(.{ .sub_path = file_target_path, .data = "nonsense" });
187 try ctx.dir.writeFile(io, .{ .sub_path = file_target_path, .data = "nonsense" });
188188 const dir_target_path = try ctx.transformPath("subdir");
189189 try ctx.dir.makeDir(dir_target_path);
190190
......@@ -487,11 +487,13 @@ test "readLinkAbsolute" {
487487 if (native_os == .wasi) return error.SkipZigTest;
488488 if (native_os == .openbsd) return error.SkipZigTest;
489489
490 const io = testing.io;
491
490492 var tmp = tmpDir(.{});
491493 defer tmp.cleanup();
492494
493495 // Create some targets
494 try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
496 try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" });
495497 try tmp.dir.makeDir("subdir");
496498
497499 // Get base abs path
......@@ -708,6 +710,7 @@ test "Dir.realpath smoke test" {
708710
709711 try testWithAllSupportedPathTypes(struct {
710712 fn impl(ctx: *TestContext) !void {
713 const io = ctx.io;
711714 const allocator = ctx.arena.allocator();
712715 const test_file_path = try ctx.transformPath("test_file");
713716 const test_dir_path = try ctx.transformPath("test_dir");
......@@ -720,7 +723,7 @@ test "Dir.realpath smoke test" {
720723 try testing.expectError(error.FileNotFound, ctx.dir.realpath(test_dir_path, &buf));
721724
722725 // Now create the file and dir
723 try ctx.dir.writeFile(.{ .sub_path = test_file_path, .data = "" });
726 try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" });
724727 try ctx.dir.makeDir(test_dir_path);
725728
726729 const base_path = try ctx.transformPath(".");
......@@ -803,11 +806,12 @@ test "readFileAlloc" {
803806test "Dir.statFile" {
804807 try testWithAllSupportedPathTypes(struct {
805808 fn impl(ctx: *TestContext) !void {
809 const io = ctx.io;
806810 const test_file_name = try ctx.transformPath("test_file");
807811
808812 try testing.expectError(error.FileNotFound, ctx.dir.statFile(test_file_name));
809813
810 try ctx.dir.writeFile(.{ .sub_path = test_file_name, .data = "" });
814 try ctx.dir.writeFile(io, .{ .sub_path = test_file_name, .data = "" });
811815
812816 const stat = try ctx.dir.statFile(test_file_name);
813817 try testing.expectEqual(File.Kind.file, stat.kind);
......@@ -925,6 +929,7 @@ test "makeOpenPath parent dirs do not exist" {
925929test "deleteDir" {
926930 try testWithAllSupportedPathTypes(struct {
927931 fn impl(ctx: *TestContext) !void {
932 const io = ctx.io;
928933 const test_dir_path = try ctx.transformPath("test_dir");
929934 const test_file_path = try ctx.transformPath("test_dir" ++ fs.path.sep_str ++ "test_file");
930935
......@@ -933,7 +938,7 @@ test "deleteDir" {
933938
934939 // deleting a non-empty directory
935940 try ctx.dir.makeDir(test_dir_path);
936 try ctx.dir.writeFile(.{ .sub_path = test_file_path, .data = "" });
941 try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" });
937942 try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path));
938943
939944 // deleting an empty directory
......@@ -1217,7 +1222,7 @@ test "deleteTree on a symlink" {
12171222 defer tmp.cleanup();
12181223
12191224 // Symlink to a file
1220 try tmp.dir.writeFile(.{ .sub_path = "file", .data = "" });
1225 try tmp.dir.writeFile(io, .{ .sub_path = "file", .data = "" });
12211226 try setupSymlink(tmp.dir, "file", "filelink", .{});
12221227
12231228 try tmp.dir.deleteTree("filelink");
......@@ -1241,11 +1246,11 @@ test "makePath, put some files in it, deleteTree" {
12411246 const dir_path = try ctx.transformPath("os_test_tmp");
12421247
12431248 try ctx.dir.makePath(io, try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
1244 try ctx.dir.writeFile(.{
1249 try ctx.dir.writeFile(io, .{
12451250 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
12461251 .data = "nonsense",
12471252 });
1248 try ctx.dir.writeFile(.{
1253 try ctx.dir.writeFile(io, .{
12491254 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }),
12501255 .data = "blah",
12511256 });
......@@ -1264,11 +1269,11 @@ test "makePath, put some files in it, deleteTreeMinStackSize" {
12641269 const dir_path = try ctx.transformPath("os_test_tmp");
12651270
12661271 try ctx.dir.makePath(io, try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
1267 try ctx.dir.writeFile(.{
1272 try ctx.dir.writeFile(io, .{
12681273 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
12691274 .data = "nonsense",
12701275 });
1271 try ctx.dir.writeFile(.{
1276 try ctx.dir.writeFile(io, .{
12721277 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }),
12731278 .data = "blah",
12741279 });
......@@ -1298,7 +1303,7 @@ test "makePath but sub_path contains pre-existing file" {
12981303 defer tmp.cleanup();
12991304
13001305 try tmp.dir.makeDir("foo");
1301 try tmp.dir.writeFile(.{ .sub_path = "foo/bar", .data = "" });
1306 try tmp.dir.writeFile(io, .{ .sub_path = "foo/bar", .data = "" });
13021307
13031308 try testing.expectError(error.NotDir, tmp.dir.makePath(io, "foo/bar/baz"));
13041309}
......@@ -1400,7 +1405,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8) !vo
14001405 var maxed_dir = try iterable_dir.makeOpenPath(maxed_filename, .{});
14011406 defer maxed_dir.close(io);
14021407
1403 try maxed_dir.writeFile(.{ .sub_path = maxed_filename, .data = "" });
1408 try maxed_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" });
14041409
14051410 var walker = try iterable_dir.walk(testing.allocator);
14061411 defer walker.deinit();
......@@ -1513,7 +1518,7 @@ test "setEndPos" {
15131518 defer tmp.cleanup();
15141519
15151520 const file_name = "afile.txt";
1516 try tmp.dir.writeFile(.{ .sub_path = file_name, .data = "ninebytes" });
1521 try tmp.dir.writeFile(io, .{ .sub_path = file_name, .data = "ninebytes" });
15171522 const f = try tmp.dir.openFile(io, file_name, .{ .mode = .read_write });
15181523 defer f.close(io);
15191524
......@@ -1563,7 +1568,7 @@ test "access file" {
15631568 try ctx.dir.makePath(io, dir_path);
15641569 try testing.expectError(error.FileNotFound, ctx.dir.access(io, file_path, .{}));
15651570
1566 try ctx.dir.writeFile(.{ .sub_path = file_path, .data = "" });
1571 try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" });
15671572 try ctx.dir.access(io, file_path, .{});
15681573 try ctx.dir.deleteTree(dir_path);
15691574 }
......@@ -1659,12 +1664,13 @@ test "sendfile with buffered data" {
16591664test "copyFile" {
16601665 try testWithAllSupportedPathTypes(struct {
16611666 fn impl(ctx: *TestContext) !void {
1667 const io = ctx.io;
16621668 const data = "u6wj+JmdF3qHsFPE BUlH2g4gJCmEz0PP";
16631669 const src_file = try ctx.transformPath("tmp_test_copy_file.txt");
16641670 const dest_file = try ctx.transformPath("tmp_test_copy_file2.txt");
16651671 const dest_file2 = try ctx.transformPath("tmp_test_copy_file3.txt");
16661672
1667 try ctx.dir.writeFile(.{ .sub_path = src_file, .data = data });
1673 try ctx.dir.writeFile(io, .{ .sub_path = src_file, .data = data });
16681674 defer ctx.dir.deleteFile(src_file) catch {};
16691675
16701676 try ctx.dir.copyFile(src_file, ctx.dir, dest_file, .{});
......@@ -2050,7 +2056,7 @@ test "'.' and '..' in Io.Dir functions" {
20502056 renamed_file.close(io);
20512057 try ctx.dir.deleteFile(rename_path);
20522058
2053 try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
2059 try ctx.dir.writeFile(io, .{ .sub_path = update_path, .data = "something" });
20542060 var dir = ctx.dir;
20552061 const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});
20562062 try testing.expectEqual(Io.Dir.PrevStatus.stale, prev_status);
......@@ -2187,7 +2193,7 @@ test "invalid UTF-8/WTF-8 paths" {
21872193 try testing.expectError(expected_err, ctx.dir.deleteTree(invalid_path));
21882194 try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path));
21892195
2190 try testing.expectError(expected_err, ctx.dir.writeFile(.{ .sub_path = invalid_path, .data = "" }));
2196 try testing.expectError(expected_err, ctx.dir.writeFile(io, .{ .sub_path = invalid_path, .data = "" }));
21912197
21922198 try testing.expectError(expected_err, ctx.dir.access(invalid_path, .{}));
21932199
......@@ -2304,7 +2310,7 @@ test "seekBy" {
23042310 var tmp_dir = testing.tmpDir(.{});
23052311 defer tmp_dir.cleanup();
23062312
2307 try tmp_dir.dir.writeFile(.{ .sub_path = "blah.txt", .data = "let's test seekBy" });
2313 try tmp_dir.dir.writeFile(io, .{ .sub_path = "blah.txt", .data = "let's test seekBy" });
23082314 const f = try tmp_dir.dir.openFile(io, "blah.txt", .{ .mode = .read_only });
23092315 defer f.close(io);
23102316 var reader = f.readerStreaming(io, &.{});
......@@ -2350,7 +2356,7 @@ test "File.Writer sendfile with buffered contents" {
23502356 defer tmp_dir.cleanup();
23512357
23522358 {
2353 try tmp_dir.dir.writeFile(.{ .sub_path = "a", .data = "bcd" });
2359 try tmp_dir.dir.writeFile(io, .{ .sub_path = "a", .data = "bcd" });
23542360 const in = try tmp_dir.dir.openFile(io, "a", .{});
23552361 defer in.close(io);
23562362 const out = try tmp_dir.dir.createFile(io, "b", .{});
......@@ -2391,11 +2397,13 @@ fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void {
23912397}
23922398
23932399test "readlinkat" {
2400 const io = testing.io;
2401
23942402 var tmp = tmpDir(.{});
23952403 defer tmp.cleanup();
23962404
23972405 // create file
2398 try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
2406 try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" });
23992407
24002408 // create a symbolic link
24012409 if (native_os == .windows) {
lib/std/posix/test.zig+1-1
......@@ -145,7 +145,7 @@ test "linkat with different directories" {
145145 const subdir = try tmp.dir.makeOpenPath("subdir", .{});
146146
147147 defer tmp.dir.deleteFile(target_name) catch {};
148 try tmp.dir.writeFile(.{ .sub_path = target_name, .data = "example" });
148 try tmp.dir.writeFile(io, .{ .sub_path = target_name, .data = "example" });
149149
150150 // Test 1: link from file in subdir back up to target in parent directory
151151 try posix.linkat(tmp.dir.handle, target_name, subdir.handle, link_name, 0);
src/Compilation.zig+2-2
......@@ -5715,7 +5715,7 @@ pub fn translateC(
57155715 const out_h_sub_path = tmp_sub_path ++ fs.path.sep_str ++ cimport_basename;
57165716 const out_h_path = try comp.dirs.local_cache.join(arena, &.{out_h_sub_path});
57175717 if (comp.verbose_cimport) log.info("writing C import source to {s}", .{out_h_path});
5718 try cache_dir.writeFile(.{ .sub_path = out_h_sub_path, .data = c_src });
5718 try cache_dir.writeFile(io, .{ .sub_path = out_h_sub_path, .data = c_src });
57195719 break :path out_h_path;
57205720 },
57215721 .path => |p| p,
......@@ -6572,7 +6572,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
65726572 resource_id, resource_type, fmtRcEscape(src_path),
65736573 });
65746574
6575 try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
6575 try o_dir.writeFile(io, .{ .sub_path = rc_basename, .data = input });
65766576
65776577 var argv = std.array_list.Managed([]const u8).init(comp.gpa);
65786578 defer argv.deinit();
src/libs/freebsd.zig+2-2
......@@ -520,7 +520,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
520520 for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
521521 try map_contents.print("FBSD_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
522522 }
523 try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
523 try o_directory.handle.writeFile(io, .{ .sub_path = all_map_basename, .data = map_contents.items });
524524 map_contents.deinit();
525525 }
526526
......@@ -974,7 +974,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
974974
975975 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "stdthreads", etc.
976976 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
977 try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
977 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
978978 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
979979 }
980980
src/libs/glibc.zig+2-2
......@@ -759,7 +759,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
759759 try map_contents.print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });
760760 }
761761 }
762 try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
762 try o_directory.handle.writeFile(io, .{ .sub_path = all_map_basename, .data = map_contents.items });
763763 map_contents.deinit(); // The most recent allocation of an arena can be freed :)
764764 }
765765
......@@ -1118,7 +1118,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
11181118
11191119 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
11201120 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
1121 try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
1121 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
11221122 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
11231123 }
11241124
src/libs/netbsd.zig+1-1
......@@ -628,7 +628,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
628628
629629 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
630630 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
631 try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
631 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
632632 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
633633 }
634634
src/main.zig+3-3
......@@ -7164,7 +7164,7 @@ fn cmdFetch(
71647164 try ast.render(gpa, &aw.writer, fixups);
71657165 const rendered = aw.written();
71667166
7167 build_root.directory.handle.writeFile(.{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| {
7167 build_root.directory.handle.writeFile(io, .{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| {
71687168 fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err });
71697169 };
71707170
......@@ -7207,7 +7207,7 @@ fn createDependenciesModule(
72077207 {
72087208 var tmp_dir = try dirs.local_cache.handle.makeOpenPath(tmp_dir_sub_path, .{});
72097209 defer tmp_dir.close(io);
7210 try tmp_dir.writeFile(.{ .sub_path = basename, .data = source });
7210 try tmp_dir.writeFile(io, .{ .sub_path = basename, .data = source });
72117211 }
72127212
72137213 var hh: Cache.HashHelper = .{};
......@@ -7438,7 +7438,7 @@ const Templates = struct {
74387438 i += 1;
74397439 }
74407440
7441 return out_dir.writeFile(.{
7441 return out_dir.writeFile(io, .{
74427442 .sub_path = template_path,
74437443 .data = templates.buffer.items,
74447444 .flags = .{ .exclusive = true },