authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-05-02 20:54:48-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-03 13:29:22-07:00
logb86c4bde64b2c0d01e4d582798ac1b84dd50b99b
tree1e58edebb2bac2b4a7bee4e5d663ea5cb0cbf248
parenta52f12afc97c5973cfb844be01cf40a9a6fdb57a

Rename Dir.writeFile2 -> Dir.writeFile and update all callsites

writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.

23 files changed, 83 insertions(+), 82 deletions(-)

lib/compiler/build_runner.zig+1-1
...@@ -308,7 +308,7 @@ pub fn main() !void {...@@ -308,7 +308,7 @@ pub fn main() !void {
308 }308 }
309 const s = std.fs.path.sep_str;309 const s = std.fs.path.sep_str;
310 const tmp_sub_path = "tmp" ++ s ++ (output_tmp_nonce orelse fatal("missing -Z arg", .{}));310 const tmp_sub_path = "tmp" ++ s ++ (output_tmp_nonce orelse fatal("missing -Z arg", .{}));
311 local_cache_directory.handle.writeFile2(.{311 local_cache_directory.handle.writeFile(.{
312 .sub_path = tmp_sub_path,312 .sub_path = tmp_sub_path,
313 .data = buffer.items,313 .data = buffer.items,
314 .flags = .{ .exclusive = true },314 .flags = .{ .exclusive = true },
lib/compiler/reduce.zig+2-2
...@@ -233,7 +233,7 @@ pub fn main() !void {...@@ -233,7 +233,7 @@ pub fn main() !void {
233 }233 }
234 }234 }
235235
236 try std.fs.cwd().writeFile(root_source_file_path, rendered.items);236 try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.items });
237 // std.debug.print("trying this code:\n{s}\n", .{rendered.items});237 // std.debug.print("trying this code:\n{s}\n", .{rendered.items});
238238
239 const interestingness = try runCheck(arena, interestingness_argv.items);239 const interestingness = try runCheck(arena, interestingness_argv.items);
...@@ -274,7 +274,7 @@ pub fn main() !void {...@@ -274,7 +274,7 @@ pub fn main() !void {
274 fixups.clearRetainingCapacity();274 fixups.clearRetainingCapacity();
275 rendered.clearRetainingCapacity();275 rendered.clearRetainingCapacity();
276 try tree.renderToArrayList(&rendered, fixups);276 try tree.renderToArrayList(&rendered, fixups);
277 try std.fs.cwd().writeFile(root_source_file_path, rendered.items);277 try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.items });
278278
279 return std.process.cleanExit();279 return std.process.cleanExit();
280 }280 }
lib/compiler/resinator/main.zig+1-1
...@@ -178,7 +178,7 @@ pub fn main() !void {...@@ -178,7 +178,7 @@ pub fn main() !void {
178 defer allocator.free(full_input);178 defer allocator.free(full_input);
179179
180 if (options.preprocess == .only) {180 if (options.preprocess == .only) {
181 try std.fs.cwd().writeFile(options.output_filename, full_input);181 try std.fs.cwd().writeFile(.{ .sub_path = options.output_filename, .data = full_input });
182 return;182 return;
183 }183 }
184184
lib/std/Build/Cache.zig+7-7
...@@ -1005,7 +1005,7 @@ pub fn readSmallFile(dir: fs.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {...@@ -1005,7 +1005,7 @@ pub fn readSmallFile(dir: fs.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {
1005pub fn writeSmallFile(dir: fs.Dir, sub_path: []const u8, data: []const u8) !void {1005pub fn writeSmallFile(dir: fs.Dir, sub_path: []const u8, data: []const u8) !void {
1006 assert(data.len <= 255);1006 assert(data.len <= 255);
1007 if (builtin.os.tag == .windows) {1007 if (builtin.os.tag == .windows) {
1008 return dir.writeFile(sub_path, data);1008 return dir.writeFile(.{ .sub_path = sub_path, .data = data });
1009 } else {1009 } else {
1010 return dir.symLink(data, sub_path, .{});1010 return dir.symLink(data, sub_path, .{});
1011 }1011 }
...@@ -1052,7 +1052,7 @@ test "cache file and then recall it" {...@@ -1052,7 +1052,7 @@ test "cache file and then recall it" {
1052 const temp_file = "test.txt";1052 const temp_file = "test.txt";
1053 const temp_manifest_dir = "temp_manifest_dir";1053 const temp_manifest_dir = "temp_manifest_dir";
10541054
1055 try tmp.dir.writeFile(temp_file, "Hello, world!\n");1055 try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = "Hello, world!\n" });
10561056
1057 // Wait for file timestamps to tick1057 // Wait for file timestamps to tick
1058 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);1058 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
...@@ -1120,7 +1120,7 @@ test "check that changing a file makes cache fail" {...@@ -1120,7 +1120,7 @@ test "check that changing a file makes cache fail" {
1120 const original_temp_file_contents = "Hello, world!\n";1120 const original_temp_file_contents = "Hello, world!\n";
1121 const updated_temp_file_contents = "Hello, world; but updated!\n";1121 const updated_temp_file_contents = "Hello, world; but updated!\n";
11221122
1123 try tmp.dir.writeFile(temp_file, original_temp_file_contents);1123 try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = original_temp_file_contents });
11241124
1125 // Wait for file timestamps to tick1125 // Wait for file timestamps to tick
1126 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);1126 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
...@@ -1156,7 +1156,7 @@ test "check that changing a file makes cache fail" {...@@ -1156,7 +1156,7 @@ test "check that changing a file makes cache fail" {
1156 try ch.writeManifest();1156 try ch.writeManifest();
1157 }1157 }
11581158
1159 try tmp.dir.writeFile(temp_file, updated_temp_file_contents);1159 try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = updated_temp_file_contents });
11601160
1161 {1161 {
1162 var ch = cache.obtain();1162 var ch = cache.obtain();
...@@ -1241,8 +1241,8 @@ test "Manifest with files added after initial hash work" {...@@ -1241,8 +1241,8 @@ test "Manifest with files added after initial hash work" {
1241 const temp_file2 = "cache_hash_post_file_test2.txt";1241 const temp_file2 = "cache_hash_post_file_test2.txt";
1242 const temp_manifest_dir = "cache_hash_post_file_manifest_dir";1242 const temp_manifest_dir = "cache_hash_post_file_manifest_dir";
12431243
1244 try tmp.dir.writeFile(temp_file1, "Hello, world!\n");1244 try tmp.dir.writeFile(.{ .sub_path = temp_file1, .data = "Hello, world!\n" });
1245 try tmp.dir.writeFile(temp_file2, "Hello world the second!\n");1245 try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
12461246
1247 // Wait for file timestamps to tick1247 // Wait for file timestamps to tick
1248 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);1248 const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
...@@ -1292,7 +1292,7 @@ test "Manifest with files added after initial hash work" {...@@ -1292,7 +1292,7 @@ test "Manifest with files added after initial hash work" {
1292 try testing.expect(mem.eql(u8, &digest1, &digest2));1292 try testing.expect(mem.eql(u8, &digest1, &digest2));
12931293
1294 // Modify the file added after initial hash1294 // Modify the file added after initial hash
1295 try tmp.dir.writeFile(temp_file2, "Hello world the second, updated\n");1295 try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
12961296
1297 // Wait for file timestamps to tick1297 // Wait for file timestamps to tick
1298 const initial_time2 = try testGetCurrentFileTimestamp(tmp.dir);1298 const initial_time2 = try testGetCurrentFileTimestamp(tmp.dir);
lib/std/Build/Step/Compile.zig+1-1
...@@ -1711,7 +1711,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1711,7 +1711,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
1711 );1711 );
17121712
1713 const args_file = "args" ++ fs.path.sep_str ++ args_hex_hash;1713 const args_file = "args" ++ fs.path.sep_str ++ args_hex_hash;
1714 try b.cache_root.handle.writeFile(args_file, args);1714 try b.cache_root.handle.writeFile(.{ .sub_path = args_file, .data = args });
17151715
1716 const resolved_args_file = try mem.concat(arena, u8, &.{1716 const resolved_args_file = try mem.concat(arena, u8, &.{
1717 "@",1717 "@",
lib/std/Build/Step/ConfigHeader.zig+1-1
...@@ -246,7 +246,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -246,7 +246,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
246 });246 });
247 };247 };
248248
249 b.cache_root.handle.writeFile(sub_path, output.items) catch |err| {249 b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = output.items }) catch |err| {
250 return step.fail("unable to write file '{}{s}': {s}", .{250 return step.fail("unable to write file '{}{s}': {s}", .{
251 b.cache_root, sub_path, @errorName(err),251 b.cache_root, sub_path, @errorName(err),
252 });252 });
lib/std/Build/Step/Options.zig+1-1
...@@ -464,7 +464,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -464,7 +464,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
464 });464 });
465 };465 };
466466
467 b.cache_root.handle.writeFile(tmp_sub_path, self.contents.items) catch |err| {467 b.cache_root.handle.writeFile(.{ .sub_path = tmp_sub_path, .data = self.contents.items }) catch |err| {
468 return step.fail("unable to write options to '{}{s}': {s}", .{468 return step.fail("unable to write options to '{}{s}': {s}", .{
469 b.cache_root, tmp_sub_path, @errorName(err),469 b.cache_root, tmp_sub_path, @errorName(err),
470 });470 });
lib/std/Build/Step/Run.zig+1-1
...@@ -930,7 +930,7 @@ fn runCommand(...@@ -930,7 +930,7 @@ fn runCommand(
930 b.cache_root, sub_path_dirname, @errorName(err),930 b.cache_root, sub_path_dirname, @errorName(err),
931 });931 });
932 };932 };
933 b.cache_root.handle.writeFile(sub_path, stream.bytes.?) catch |err| {933 b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = stream.bytes.? }) catch |err| {
934 return step.fail("unable to write file '{}{s}': {s}", .{934 return step.fail("unable to write file '{}{s}': {s}", .{
935 b.cache_root, sub_path, @errorName(err),935 b.cache_root, sub_path, @errorName(err),
936 });936 });
lib/std/Build/Step/WriteFile.zig+2-2
...@@ -218,7 +218,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -218,7 +218,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
218 }218 }
219 switch (output_source_file.contents) {219 switch (output_source_file.contents) {
220 .bytes => |bytes| {220 .bytes => |bytes| {
221 b.build_root.handle.writeFile(output_source_file.sub_path, bytes) catch |err| {221 b.build_root.handle.writeFile(.{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
222 return step.fail("unable to write file '{}{s}': {s}", .{222 return step.fail("unable to write file '{}{s}': {s}", .{
223 b.build_root, output_source_file.sub_path, @errorName(err),223 b.build_root, output_source_file.sub_path, @errorName(err),
224 });224 });
...@@ -311,7 +311,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -311,7 +311,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
311 }311 }
312 switch (file.contents) {312 switch (file.contents) {
313 .bytes => |bytes| {313 .bytes => |bytes| {
314 cache_dir.writeFile(file.sub_path, bytes) catch |err| {314 cache_dir.writeFile(.{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
315 return step.fail("unable to write file '{}{s}{c}{s}': {s}", .{315 return step.fail("unable to write file '{}{s}{c}{s}': {s}", .{
316 b.cache_root, cache_path, fs.path.sep, file.sub_path, @errorName(err),316 b.cache_root, cache_path, fs.path.sep, file.sub_path, @errorName(err),
317 });317 });
lib/std/debug.zig+6-3
...@@ -1524,7 +1524,7 @@ test printLineFromFileAnyOs {...@@ -1524,7 +1524,7 @@ test printLineFromFileAnyOs {
1524 {1524 {
1525 const path = try join(allocator, &.{ test_dir_path, "one_line.zig" });1525 const path = try join(allocator, &.{ test_dir_path, "one_line.zig" });
1526 defer allocator.free(path);1526 defer allocator.free(path);
1527 try test_dir.dir.writeFile("one_line.zig", "no new lines in this file, but one is printed anyway");1527 try test_dir.dir.writeFile(.{ .sub_path = "one_line.zig", .data = "no new lines in this file, but one is printed anyway" });
15281528
1529 try expectError(error.EndOfFile, printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 }));1529 try expectError(error.EndOfFile, printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
15301530
...@@ -1535,11 +1535,14 @@ test printLineFromFileAnyOs {...@@ -1535,11 +1535,14 @@ test printLineFromFileAnyOs {
1535 {1535 {
1536 const path = try fs.path.join(allocator, &.{ test_dir_path, "three_lines.zig" });1536 const path = try fs.path.join(allocator, &.{ test_dir_path, "three_lines.zig" });
1537 defer allocator.free(path);1537 defer allocator.free(path);
1538 try test_dir.dir.writeFile("three_lines.zig",1538 try test_dir.dir.writeFile(.{
1539 .sub_path = "three_lines.zig",
1540 .data =
1539 \\11541 \\1
1540 \\21542 \\2
1541 \\31543 \\3
1542 );1544 ,
1545 });
15431546
1544 try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });1547 try printLineFromFileAnyOs(output_stream, .{ .file_name = path, .line = 1, .column = 0 });
1545 try expectEqualStrings("1\n", output.items);1548 try expectEqualStrings("1\n", output.items);
lib/std/fs/Dir.zig+3-13
...@@ -2339,18 +2339,6 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File...@@ -2339,18 +2339,6 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
23392339
2340pub const WriteFileError = File.WriteError || File.OpenError;2340pub const WriteFileError = File.WriteError || File.OpenError;
23412341
2342/// Deprecated: use `writeFile2`.
2343/// On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
2344/// On WASI, `sub_path` should be encoded as valid UTF-8.
2345/// On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
2346pub fn writeFile(self: Dir, sub_path: []const u8, data: []const u8) WriteFileError!void {
2347 return writeFile2(self, .{
2348 .sub_path = sub_path,
2349 .data = data,
2350 .flags = .{},
2351 });
2352}
2353
2354pub const WriteFileOptions = struct {2342pub const WriteFileOptions = struct {
2355 /// On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).2343 /// On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
2356 /// On WASI, `sub_path` should be encoded as valid UTF-8.2344 /// On WASI, `sub_path` should be encoded as valid UTF-8.
...@@ -2361,12 +2349,14 @@ pub const WriteFileOptions = struct {...@@ -2361,12 +2349,14 @@ pub const WriteFileOptions = struct {
2361};2349};
23622350
2363/// Writes content to the file system, using the file creation flags provided.2351/// Writes content to the file system, using the file creation flags provided.
2364pub fn writeFile2(self: Dir, options: WriteFileOptions) WriteFileError!void {2352pub fn writeFile(self: Dir, options: WriteFileOptions) WriteFileError!void {
2365 var file = try self.createFile(options.sub_path, options.flags);2353 var file = try self.createFile(options.sub_path, options.flags);
2366 defer file.close();2354 defer file.close();
2367 try file.writeAll(options.data);2355 try file.writeAll(options.data);
2368}2356}
23692357
2358pub const writeFile2 = @compileError("deprecated; renamed to writeFile");
2359
2370pub const AccessError = posix.AccessError;2360pub const AccessError = posix.AccessError;
23712361
2372/// Test accessing `sub_path`.2362/// Test accessing `sub_path`.
lib/std/fs/test.zig+28-20
...@@ -178,7 +178,7 @@ test "Dir.readLink" {...@@ -178,7 +178,7 @@ test "Dir.readLink" {
178 fn impl(ctx: *TestContext) !void {178 fn impl(ctx: *TestContext) !void {
179 // Create some targets179 // Create some targets
180 const file_target_path = try ctx.transformPath("file.txt");180 const file_target_path = try ctx.transformPath("file.txt");
181 try ctx.dir.writeFile(file_target_path, "nonsense");181 try ctx.dir.writeFile(.{ .sub_path = file_target_path, .data = "nonsense" });
182 const dir_target_path = try ctx.transformPath("subdir");182 const dir_target_path = try ctx.transformPath("subdir");
183 try ctx.dir.makeDir(dir_target_path);183 try ctx.dir.makeDir(dir_target_path);
184184
...@@ -398,7 +398,7 @@ test "readLinkAbsolute" {...@@ -398,7 +398,7 @@ test "readLinkAbsolute" {
398 defer tmp.cleanup();398 defer tmp.cleanup();
399399
400 // Create some targets400 // Create some targets
401 try tmp.dir.writeFile("file.txt", "nonsense");401 try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
402 try tmp.dir.makeDir("subdir");402 try tmp.dir.makeDir("subdir");
403403
404 // Get base abs path404 // Get base abs path
...@@ -620,7 +620,7 @@ test "Dir.realpath smoke test" {...@@ -620,7 +620,7 @@ test "Dir.realpath smoke test" {
620 try testing.expectError(error.FileNotFound, ctx.dir.realpath(test_dir_path, &buf));620 try testing.expectError(error.FileNotFound, ctx.dir.realpath(test_dir_path, &buf));
621621
622 // Now create the file and dir622 // Now create the file and dir
623 try ctx.dir.writeFile(test_file_path, "");623 try ctx.dir.writeFile(.{ .sub_path = test_file_path, .data = "" });
624 try ctx.dir.makeDir(test_dir_path);624 try ctx.dir.makeDir(test_dir_path);
625625
626 const base_path = try ctx.transformPath(".");626 const base_path = try ctx.transformPath(".");
...@@ -695,7 +695,7 @@ test "Dir.statFile" {...@@ -695,7 +695,7 @@ test "Dir.statFile" {
695695
696 try testing.expectError(error.FileNotFound, ctx.dir.statFile(test_file_name));696 try testing.expectError(error.FileNotFound, ctx.dir.statFile(test_file_name));
697697
698 try ctx.dir.writeFile(test_file_name, "");698 try ctx.dir.writeFile(.{ .sub_path = test_file_name, .data = "" });
699699
700 const stat = try ctx.dir.statFile(test_file_name);700 const stat = try ctx.dir.statFile(test_file_name);
701 try testing.expectEqual(File.Kind.file, stat.kind);701 try testing.expectEqual(File.Kind.file, stat.kind);
...@@ -803,7 +803,7 @@ test "deleteDir" {...@@ -803,7 +803,7 @@ test "deleteDir" {
803803
804 // deleting a non-empty directory804 // deleting a non-empty directory
805 try ctx.dir.makeDir(test_dir_path);805 try ctx.dir.makeDir(test_dir_path);
806 try ctx.dir.writeFile(test_file_path, "");806 try ctx.dir.writeFile(.{ .sub_path = test_file_path, .data = "" });
807 try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path));807 try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path));
808808
809 // deleting an empty directory809 // deleting an empty directory
...@@ -1071,7 +1071,7 @@ test "deleteTree on a symlink" {...@@ -1071,7 +1071,7 @@ test "deleteTree on a symlink" {
1071 defer tmp.cleanup();1071 defer tmp.cleanup();
10721072
1073 // Symlink to a file1073 // Symlink to a file
1074 try tmp.dir.writeFile("file", "");1074 try tmp.dir.writeFile(.{ .sub_path = "file", .data = "" });
1075 try setupSymlink(tmp.dir, "file", "filelink", .{});1075 try setupSymlink(tmp.dir, "file", "filelink", .{});
10761076
1077 try tmp.dir.deleteTree("filelink");1077 try tmp.dir.deleteTree("filelink");
...@@ -1094,8 +1094,14 @@ test "makePath, put some files in it, deleteTree" {...@@ -1094,8 +1094,14 @@ test "makePath, put some files in it, deleteTree" {
1094 const dir_path = try ctx.transformPath("os_test_tmp");1094 const dir_path = try ctx.transformPath("os_test_tmp");
10951095
1096 try ctx.dir.makePath(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));1096 try ctx.dir.makePath(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
1097 try ctx.dir.writeFile(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }), "nonsense");1097 try ctx.dir.writeFile(.{
1098 try ctx.dir.writeFile(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }), "blah");1098 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
1099 .data = "nonsense",
1100 });
1101 try ctx.dir.writeFile(.{
1102 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }),
1103 .data = "blah",
1104 });
10991105
1100 try ctx.dir.deleteTree(dir_path);1106 try ctx.dir.deleteTree(dir_path);
1101 try testing.expectError(error.FileNotFound, ctx.dir.openDir(dir_path, .{}));1107 try testing.expectError(error.FileNotFound, ctx.dir.openDir(dir_path, .{}));
...@@ -1110,8 +1116,14 @@ test "makePath, put some files in it, deleteTreeMinStackSize" {...@@ -1110,8 +1116,14 @@ test "makePath, put some files in it, deleteTreeMinStackSize" {
1110 const dir_path = try ctx.transformPath("os_test_tmp");1116 const dir_path = try ctx.transformPath("os_test_tmp");
11111117
1112 try ctx.dir.makePath(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));1118 try ctx.dir.makePath(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
1113 try ctx.dir.writeFile(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }), "nonsense");1119 try ctx.dir.writeFile(.{
1114 try ctx.dir.writeFile(try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }), "blah");1120 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
1121 .data = "nonsense",
1122 });
1123 try ctx.dir.writeFile(.{
1124 .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }),
1125 .data = "blah",
1126 });
11151127
1116 try ctx.dir.deleteTreeMinStackSize(dir_path);1128 try ctx.dir.deleteTreeMinStackSize(dir_path);
1117 try testing.expectError(error.FileNotFound, ctx.dir.openDir(dir_path, .{}));1129 try testing.expectError(error.FileNotFound, ctx.dir.openDir(dir_path, .{}));
...@@ -1134,7 +1146,7 @@ test "makePath but sub_path contains pre-existing file" {...@@ -1134,7 +1146,7 @@ test "makePath but sub_path contains pre-existing file" {
1134 defer tmp.cleanup();1146 defer tmp.cleanup();
11351147
1136 try tmp.dir.makeDir("foo");1148 try tmp.dir.makeDir("foo");
1137 try tmp.dir.writeFile("foo/bar", "");1149 try tmp.dir.writeFile(.{ .sub_path = "foo/bar", .data = "" });
11381150
1139 try testing.expectError(error.NotDir, tmp.dir.makePath("foo/bar/baz"));1151 try testing.expectError(error.NotDir, tmp.dir.makePath("foo/bar/baz"));
1140}1152}
...@@ -1227,7 +1239,7 @@ fn testFilenameLimits(iterable_dir: Dir, maxed_filename: []const u8) !void {...@@ -1227,7 +1239,7 @@ fn testFilenameLimits(iterable_dir: Dir, maxed_filename: []const u8) !void {
1227 var maxed_dir = try iterable_dir.makeOpenPath(maxed_filename, .{});1239 var maxed_dir = try iterable_dir.makeOpenPath(maxed_filename, .{});
1228 defer maxed_dir.close();1240 defer maxed_dir.close();
12291241
1230 try maxed_dir.writeFile(maxed_filename, "");1242 try maxed_dir.writeFile(.{ .sub_path = maxed_filename, .data = "" });
12311243
1232 var walker = try iterable_dir.walk(testing.allocator);1244 var walker = try iterable_dir.walk(testing.allocator);
1233 defer walker.deinit();1245 defer walker.deinit();
...@@ -1357,7 +1369,7 @@ test "access file" {...@@ -1357,7 +1369,7 @@ test "access file" {
1357 try ctx.dir.makePath(dir_path);1369 try ctx.dir.makePath(dir_path);
1358 try testing.expectError(error.FileNotFound, ctx.dir.access(file_path, .{}));1370 try testing.expectError(error.FileNotFound, ctx.dir.access(file_path, .{}));
13591371
1360 try ctx.dir.writeFile(file_path, "");1372 try ctx.dir.writeFile(.{ .sub_path = file_path, .data = "" });
1361 try ctx.dir.access(file_path, .{});1373 try ctx.dir.access(file_path, .{});
1362 try ctx.dir.deleteTree(dir_path);1374 try ctx.dir.deleteTree(dir_path);
1363 }1375 }
...@@ -1463,7 +1475,7 @@ test "copyFile" {...@@ -1463,7 +1475,7 @@ test "copyFile" {
1463 const dest_file = try ctx.transformPath("tmp_test_copy_file2.txt");1475 const dest_file = try ctx.transformPath("tmp_test_copy_file2.txt");
1464 const dest_file2 = try ctx.transformPath("tmp_test_copy_file3.txt");1476 const dest_file2 = try ctx.transformPath("tmp_test_copy_file3.txt");
14651477
1466 try ctx.dir.writeFile(src_file, data);1478 try ctx.dir.writeFile(.{ .sub_path = src_file, .data = data });
1467 defer ctx.dir.deleteFile(src_file) catch {};1479 defer ctx.dir.deleteFile(src_file) catch {};
14681480
1469 try ctx.dir.copyFile(src_file, ctx.dir, dest_file, .{});1481 try ctx.dir.copyFile(src_file, ctx.dir, dest_file, .{});
...@@ -1740,7 +1752,7 @@ test "'.' and '..' in fs.Dir functions" {...@@ -1740,7 +1752,7 @@ test "'.' and '..' in fs.Dir functions" {
1740 renamed_file.close();1752 renamed_file.close();
1741 try ctx.dir.deleteFile(rename_path);1753 try ctx.dir.deleteFile(rename_path);
17421754
1743 try ctx.dir.writeFile(update_path, "something");1755 try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
1744 const prev_status = try ctx.dir.updateFile(file_path, ctx.dir, update_path, .{});1756 const prev_status = try ctx.dir.updateFile(file_path, ctx.dir, update_path, .{});
1745 try testing.expectEqual(fs.Dir.PrevStatus.stale, prev_status);1757 try testing.expectEqual(fs.Dir.PrevStatus.stale, prev_status);
17461758
...@@ -2009,11 +2021,7 @@ test "invalid UTF-8/WTF-8 paths" {...@@ -2009,11 +2021,7 @@ test "invalid UTF-8/WTF-8 paths" {
2009 try testing.expectError(expected_err, ctx.dir.deleteTree(invalid_path));2021 try testing.expectError(expected_err, ctx.dir.deleteTree(invalid_path));
2010 try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path));2022 try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path));
20112023
2012 try testing.expectError(expected_err, ctx.dir.writeFile(invalid_path, ""));2024 try testing.expectError(expected_err, ctx.dir.writeFile(.{ .sub_path = invalid_path, .data = "" }));
2013 try testing.expectError(expected_err, ctx.dir.writeFile2(.{
2014 .sub_path = invalid_path,
2015 .data = "",
2016 }));
20172025
2018 try testing.expectError(expected_err, ctx.dir.access(invalid_path, .{}));2026 try testing.expectError(expected_err, ctx.dir.access(invalid_path, .{}));
2019 try testing.expectError(expected_err, ctx.dir.accessZ(invalid_path, .{}));2027 try testing.expectError(expected_err, ctx.dir.accessZ(invalid_path, .{}));
lib/std/posix/test.zig+5-5
...@@ -209,7 +209,7 @@ test "symlink with relative paths" {...@@ -209,7 +209,7 @@ test "symlink with relative paths" {
209 cwd.deleteFile("symlinked") catch {};209 cwd.deleteFile("symlinked") catch {};
210210
211 // First, try relative paths in cwd211 // First, try relative paths in cwd
212 try cwd.writeFile("file.txt", "nonsense");212 try cwd.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
213213
214 if (native_os == .windows) {214 if (native_os == .windows) {
215 std.os.windows.CreateSymbolicLink(215 std.os.windows.CreateSymbolicLink(
...@@ -268,7 +268,7 @@ test "link with relative paths" {...@@ -268,7 +268,7 @@ test "link with relative paths" {
268 cwd.deleteFile("example.txt") catch {};268 cwd.deleteFile("example.txt") catch {};
269 cwd.deleteFile("new.txt") catch {};269 cwd.deleteFile("new.txt") catch {};
270270
271 try cwd.writeFile("example.txt", "example");271 try cwd.writeFile(.{ .sub_path = "example.txt", .data = "example" });
272 try posix.link("example.txt", "new.txt", 0);272 try posix.link("example.txt", "new.txt", 0);
273273
274 const efd = try cwd.openFile("example.txt", .{});274 const efd = try cwd.openFile("example.txt", .{});
...@@ -312,7 +312,7 @@ test "linkat with different directories" {...@@ -312,7 +312,7 @@ test "linkat with different directories" {
312 cwd.deleteFile("example.txt") catch {};312 cwd.deleteFile("example.txt") catch {};
313 tmp.dir.deleteFile("new.txt") catch {};313 tmp.dir.deleteFile("new.txt") catch {};
314314
315 try cwd.writeFile("example.txt", "example");315 try cwd.writeFile(.{ .sub_path = "example.txt", .data = "example" });
316 try posix.linkat(cwd.fd, "example.txt", tmp.dir.fd, "new.txt", 0);316 try posix.linkat(cwd.fd, "example.txt", tmp.dir.fd, "new.txt", 0);
317317
318 const efd = try cwd.openFile("example.txt", .{});318 const efd = try cwd.openFile("example.txt", .{});
...@@ -348,7 +348,7 @@ test "fstatat" {...@@ -348,7 +348,7 @@ test "fstatat" {
348348
349 // create dummy file349 // create dummy file
350 const contents = "nonsense";350 const contents = "nonsense";
351 try tmp.dir.writeFile("file.txt", contents);351 try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = contents });
352352
353 // fetch file's info on the opened fd directly353 // fetch file's info on the opened fd directly
354 const file = try tmp.dir.openFile("file.txt", .{});354 const file = try tmp.dir.openFile("file.txt", .{});
...@@ -366,7 +366,7 @@ test "readlinkat" {...@@ -366,7 +366,7 @@ test "readlinkat" {
366 defer tmp.cleanup();366 defer tmp.cleanup();
367367
368 // create file368 // create file
369 try tmp.dir.writeFile("file.txt", "nonsense");369 try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
370370
371 // create a symbolic link371 // create a symbolic link
372 if (native_os == .windows) {372 if (native_os == .windows) {
src/Compilation.zig+2-2
...@@ -4175,7 +4175,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module...@@ -4175,7 +4175,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8, owner_mod: *Package.Module
4175 });4175 });
4176 const out_dep_path = try std.fmt.allocPrint(arena, "{s}.d", .{out_h_path});4176 const out_dep_path = try std.fmt.allocPrint(arena, "{s}.d", .{out_h_path});
41774177
4178 try zig_cache_tmp_dir.writeFile(cimport_basename, c_src);4178 try zig_cache_tmp_dir.writeFile(.{ .sub_path = cimport_basename, .data = c_src });
4179 if (comp.verbose_cimport) {4179 if (comp.verbose_cimport) {
4180 log.info("C import source: {s}", .{out_h_path});4180 log.info("C import source: {s}", .{out_h_path});
4181 }4181 }
...@@ -4840,7 +4840,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -4840,7 +4840,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
4840 // 1 is CREATEPROCESS_MANIFEST_RESOURCE_ID which is the default ID used for RT_MANIFEST resources4840 // 1 is CREATEPROCESS_MANIFEST_RESOURCE_ID which is the default ID used for RT_MANIFEST resources
4841 // 24 is RT_MANIFEST4841 // 24 is RT_MANIFEST
4842 const input = try std.fmt.allocPrint(arena, "1 24 \"{s}\"", .{fmtRcEscape(src_path)});4842 const input = try std.fmt.allocPrint(arena, "1 24 \"{s}\"", .{fmtRcEscape(src_path)});
4843 try o_dir.writeFile(rc_basename, input);4843 try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
48444844
4845 var argv = std.ArrayList([]const u8).init(comp.gpa);4845 var argv = std.ArrayList([]const u8).init(comp.gpa);
4846 defer argv.deinit();4846 defer argv.deinit();
src/glibc.zig+2-2
...@@ -755,7 +755,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !vo...@@ -755,7 +755,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !vo
755 try map_contents.writer().print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });755 try map_contents.writer().print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });
756 }756 }
757 }757 }
758 try o_directory.handle.writeFile(all_map_basename, map_contents.items);758 try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
759 map_contents.deinit(); // The most recent allocation of an arena can be freed :)759 map_contents.deinit(); // The most recent allocation of an arena can be freed :)
760 }760 }
761761
...@@ -1040,7 +1040,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !vo...@@ -1040,7 +1040,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: *std.Progress.Node) !vo
10401040
1041 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.1041 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
1042 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;1042 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
1043 try o_directory.handle.writeFile(asm_file_basename, stubs_asm.items);1043 try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
10441044
1045 try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);1045 try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);
1046 }1046 }
src/main.zig+3-3
...@@ -6966,7 +6966,7 @@ fn cmdFetch(...@@ -6966,7 +6966,7 @@ fn cmdFetch(
6966 defer rendered.deinit();6966 defer rendered.deinit();
6967 try ast.renderToArrayList(&rendered, fixups);6967 try ast.renderToArrayList(&rendered, fixups);
69686968
6969 build_root.directory.handle.writeFile(Package.Manifest.basename, rendered.items) catch |err| {6969 build_root.directory.handle.writeFile(.{ .sub_path = Package.Manifest.basename, .data = rendered.items }) catch |err| {
6970 fatal("unable to write {s} file: {s}", .{ Package.Manifest.basename, @errorName(err) });6970 fatal("unable to write {s} file: {s}", .{ Package.Manifest.basename, @errorName(err) });
6971 };6971 };
69726972
...@@ -7013,7 +7013,7 @@ fn createDependenciesModule(...@@ -7013,7 +7013,7 @@ fn createDependenciesModule(
7013 {7013 {
7014 var tmp_dir = try local_cache_directory.handle.makeOpenPath(tmp_dir_sub_path, .{});7014 var tmp_dir = try local_cache_directory.handle.makeOpenPath(tmp_dir_sub_path, .{});
7015 defer tmp_dir.close();7015 defer tmp_dir.close();
7016 try tmp_dir.writeFile(basename, source);7016 try tmp_dir.writeFile(.{ .sub_path = basename, .data = source });
7017 }7017 }
70187018
7019 var hh: Cache.HashHelper = .{};7019 var hh: Cache.HashHelper = .{};
...@@ -7225,7 +7225,7 @@ const Templates = struct {...@@ -7225,7 +7225,7 @@ const Templates = struct {
7225 }7225 }
7226 }7226 }
72277227
7228 return out_dir.writeFile2(.{7228 return out_dir.writeFile(.{
7229 .sub_path = template_path,7229 .sub_path = template_path,
7230 .data = templates.buffer.items,7230 .data = templates.buffer.items,
7231 .flags = .{ .exclusive = true },7231 .flags = .{ .exclusive = true },
test/src/Cases.zig+1-1
...@@ -1641,7 +1641,7 @@ fn runOneCase(...@@ -1641,7 +1641,7 @@ fn runOneCase(
1641 var sync_node = update_node.start("write", 0);1641 var sync_node = update_node.start("write", 0);
1642 sync_node.activate();1642 sync_node.activate();
1643 for (update.files.items) |file| {1643 for (update.files.items) |file| {
1644 try tmp.dir.writeFile(file.path, file.src);1644 try tmp.dir.writeFile(.{ .sub_path = file.path, .data = file.src });
1645 }1645 }
1646 sync_node.end();1646 sync_node.end();
16471647
test/standalone/windows_bat_args/fuzz.zig+3-3
...@@ -51,15 +51,15 @@ pub fn main() anyerror!void {...@@ -51,15 +51,15 @@ pub fn main() anyerror!void {
51 const preamble_len = buf.items.len;51 const preamble_len = buf.items.len;
5252
53 try buf.appendSlice(" %*");53 try buf.appendSlice(" %*");
54 try tmp.dir.writeFile("args1.bat", buf.items);54 try tmp.dir.writeFile(.{ .sub_path = "args1.bat", .data = buf.items });
55 buf.shrinkRetainingCapacity(preamble_len);55 buf.shrinkRetainingCapacity(preamble_len);
5656
57 try buf.appendSlice(" %1 %2 %3 %4 %5 %6 %7 %8 %9");57 try buf.appendSlice(" %1 %2 %3 %4 %5 %6 %7 %8 %9");
58 try tmp.dir.writeFile("args2.bat", buf.items);58 try tmp.dir.writeFile(.{ .sub_path = "args2.bat", .data = buf.items });
59 buf.shrinkRetainingCapacity(preamble_len);59 buf.shrinkRetainingCapacity(preamble_len);
6060
61 try buf.appendSlice(" \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\"");61 try buf.appendSlice(" \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\"");
62 try tmp.dir.writeFile("args3.bat", buf.items);62 try tmp.dir.writeFile(.{ .sub_path = "args3.bat", .data = buf.items });
63 buf.shrinkRetainingCapacity(preamble_len);63 buf.shrinkRetainingCapacity(preamble_len);
6464
65 var i: u64 = 0;65 var i: u64 = 0;
test/standalone/windows_bat_args/test.zig+3-3
...@@ -25,15 +25,15 @@ pub fn main() anyerror!void {...@@ -25,15 +25,15 @@ pub fn main() anyerror!void {
25 const preamble_len = buf.items.len;25 const preamble_len = buf.items.len;
2626
27 try buf.appendSlice(" %*");27 try buf.appendSlice(" %*");
28 try tmp.dir.writeFile("args1.bat", buf.items);28 try tmp.dir.writeFile(.{ .sub_path = "args1.bat", .data = buf.items });
29 buf.shrinkRetainingCapacity(preamble_len);29 buf.shrinkRetainingCapacity(preamble_len);
3030
31 try buf.appendSlice(" %1 %2 %3 %4 %5 %6 %7 %8 %9");31 try buf.appendSlice(" %1 %2 %3 %4 %5 %6 %7 %8 %9");
32 try tmp.dir.writeFile("args2.bat", buf.items);32 try tmp.dir.writeFile(.{ .sub_path = "args2.bat", .data = buf.items });
33 buf.shrinkRetainingCapacity(preamble_len);33 buf.shrinkRetainingCapacity(preamble_len);
3434
35 try buf.appendSlice(" \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\"");35 try buf.appendSlice(" \"%~1\" \"%~2\" \"%~3\" \"%~4\" \"%~5\" \"%~6\" \"%~7\" \"%~8\" \"%~9\"");
36 try tmp.dir.writeFile("args3.bat", buf.items);36 try tmp.dir.writeFile(.{ .sub_path = "args3.bat", .data = buf.items });
37 buf.shrinkRetainingCapacity(preamble_len);37 buf.shrinkRetainingCapacity(preamble_len);
3838
39 // Test cases are from https://github.com/rust-lang/rust/blob/master/tests/ui/std/windows-bat-args.rs39 // Test cases are from https://github.com/rust-lang/rust/blob/master/tests/ui/std/windows-bat-args.rs
test/standalone/windows_spawn/main.zig+3-3
...@@ -53,9 +53,9 @@ pub fn main() anyerror!void {...@@ -53,9 +53,9 @@ pub fn main() anyerror!void {
53 try testExec(allocator, "heLLo", "hello from exe\n");53 try testExec(allocator, "heLLo", "hello from exe\n");
5454
55 // now add a .bat55 // now add a .bat
56 try tmp.dir.writeFile("hello.bat", "@echo hello from bat");56 try tmp.dir.writeFile(.{ .sub_path = "hello.bat", .data = "@echo hello from bat" });
57 // and a .cmd57 // and a .cmd
58 try tmp.dir.writeFile("hello.cmd", "@echo hello from cmd");58 try tmp.dir.writeFile(.{ .sub_path = "hello.cmd", .data = "@echo hello from cmd" });
5959
60 // with extension should find the .bat (case insensitive)60 // with extension should find the .bat (case insensitive)
61 try testExec(allocator, "heLLo.bat", "hello from bat\r\n");61 try testExec(allocator, "heLLo.bat", "hello from bat\r\n");
...@@ -87,7 +87,7 @@ pub fn main() anyerror!void {...@@ -87,7 +87,7 @@ pub fn main() anyerror!void {
87 try testExec(allocator, "heLLo", "hello from bat\r\n");87 try testExec(allocator, "heLLo", "hello from bat\r\n");
8888
89 // Add a hello.exe that is not a valid executable89 // Add a hello.exe that is not a valid executable
90 try tmp.dir.writeFile("hello.exe", "invalid");90 try tmp.dir.writeFile(.{ .sub_path = "hello.exe", .data = "invalid" });
9191
92 // Trying to execute it with extension will give InvalidExe. This is a special92 // Trying to execute it with extension will give InvalidExe. This is a special
93 // case for .EXE extensions, where if they ever try to get executed but they are93 // case for .EXE extensions, where if they ever try to get executed but they are
test/tests.zig+3-3
...@@ -823,12 +823,12 @@ pub fn addCliTests(b: *std.Build) *Step {...@@ -823,12 +823,12 @@ pub fn addCliTests(b: *std.Build) *Step {
823823
824 var dir = std.fs.cwd().openDir(tmp_path, .{}) catch @panic("unhandled");824 var dir = std.fs.cwd().openDir(tmp_path, .{}) catch @panic("unhandled");
825 defer dir.close();825 defer dir.close();
826 dir.writeFile("fmt1.zig", unformatted_code) catch @panic("unhandled");826 dir.writeFile(.{ .sub_path = "fmt1.zig", .data = unformatted_code }) catch @panic("unhandled");
827 dir.writeFile("fmt2.zig", unformatted_code) catch @panic("unhandled");827 dir.writeFile(.{ .sub_path = "fmt2.zig", .data = unformatted_code }) catch @panic("unhandled");
828 dir.makeDir("subdir") catch @panic("unhandled");828 dir.makeDir("subdir") catch @panic("unhandled");
829 var subdir = dir.openDir("subdir", .{}) catch @panic("unhandled");829 var subdir = dir.openDir("subdir", .{}) catch @panic("unhandled");
830 defer subdir.close();830 defer subdir.close();
831 subdir.writeFile("fmt3.zig", unformatted_code) catch @panic("unhandled");831 subdir.writeFile(.{ .sub_path = "fmt3.zig", .data = unformatted_code }) catch @panic("unhandled");
832832
833 // Test zig fmt affecting only the appropriate files.833 // Test zig fmt affecting only the appropriate files.
834 const run1 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "fmt1.zig" });834 const run1 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "fmt1.zig" });
tools/process_headers.zig+2-2
...@@ -467,7 +467,7 @@ pub fn main() !void {...@@ -467,7 +467,7 @@ pub fn main() !void {
467 // worth it to make it generic467 // worth it to make it generic
468 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });468 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });
469 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);469 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
470 try std.fs.cwd().writeFile(full_path, best_contents.bytes);470 try std.fs.cwd().writeFile(.{ .sub_path = full_path, .data = best_contents.bytes });
471 best_contents.is_generic = true;471 best_contents.is_generic = true;
472 while (contents_list.popOrNull()) |contender| {472 while (contents_list.popOrNull()) |contender| {
473 if (contender.hit_count > 1) {473 if (contender.hit_count > 1) {
...@@ -497,7 +497,7 @@ pub fn main() !void {...@@ -497,7 +497,7 @@ pub fn main() !void {
497 });497 });
498 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });498 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });
499 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);499 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
500 try std.fs.cwd().writeFile(full_path, contents.bytes);500 try std.fs.cwd().writeFile(.{ .sub_path = full_path, .data = contents.bytes });
501 }501 }
502 }502 }
503}503}
tools/update-linux-headers.zig+2-2
...@@ -275,7 +275,7 @@ pub fn main() !void {...@@ -275,7 +275,7 @@ pub fn main() !void {
275 // worth it to make it generic275 // worth it to make it generic
276 const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });276 const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* });
277 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);277 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
278 try std.fs.cwd().writeFile(full_path, best_contents.bytes);278 try std.fs.cwd().writeFile(.{ .sub_path = full_path, .data = best_contents.bytes });
279 best_contents.is_generic = true;279 best_contents.is_generic = true;
280 while (contents_list.popOrNull()) |contender| {280 while (contents_list.popOrNull()) |contender| {
281 if (contender.hit_count > 1) {281 if (contender.hit_count > 1) {
...@@ -301,7 +301,7 @@ pub fn main() !void {...@@ -301,7 +301,7 @@ pub fn main() !void {
301 const out_subpath = try std.fmt.allocPrint(arena, "{s}-linux-any", .{arch_name});301 const out_subpath = try std.fmt.allocPrint(arena, "{s}-linux-any", .{arch_name});
302 const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });302 const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, out_subpath, path_kv.key_ptr.* });
303 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);303 try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
304 try std.fs.cwd().writeFile(full_path, contents.bytes);304 try std.fs.cwd().writeFile(.{ .sub_path = full_path, .data = contents.bytes });
305 }305 }
306 }306 }
307307