| author | |
| committer | |
| log | 4218344dd3178f2fd3d9d00e9ff6895ee344df6d |
| tree | 38a1378b45349bcd182f6bdb721dadb275c1d02e |
| parent | 950d18ef695bb7a28397e080dc3c201559ec4ee2 |
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 { |
| 459 | 459 | } |
| 460 | 460 | const s = std.fs.path.sep_str; |
| 461 | 461 | 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, .{ | |
| 463 | 463 | .sub_path = tmp_sub_path, |
| 464 | 464 | .data = buffer.items, |
| 465 | 465 | .flags = .{ .exclusive = true }, |
lib/compiler/reduce.zig+8-4| ... | ... | @@ -55,6 +55,10 @@ pub fn main() !void { |
| 55 | 55 | var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init; |
| 56 | 56 | const gpa = general_purpose_allocator.allocator(); |
| 57 | 57 | |
| 58 | var threaded: std.Io.Threaded = .init(gpa); | |
| 59 | defer threaded.deinit(); | |
| 60 | const io = threaded.io(); | |
| 61 | ||
| 58 | 62 | const args = try std.process.argsAlloc(arena); |
| 59 | 63 | |
| 60 | 64 | var opt_checker_path: ?[]const u8 = null; |
| ... | ... | @@ -233,12 +237,12 @@ pub fn main() !void { |
| 233 | 237 | } |
| 234 | 238 | } |
| 235 | 239 | |
| 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() }); | |
| 237 | 241 | // std.debug.print("trying this code:\n{s}\n", .{rendered.items}); |
| 238 | 242 | |
| 239 | 243 | 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, | |
| 242 | 246 | }); |
| 243 | 247 | switch (interestingness) { |
| 244 | 248 | .interesting => { |
| ... | ... | @@ -274,7 +278,7 @@ pub fn main() !void { |
| 274 | 278 | fixups.clearRetainingCapacity(); |
| 275 | 279 | rendered.clearRetainingCapacity(); |
| 276 | 280 | 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() }); | |
| 278 | 282 | |
| 279 | 283 | return std.process.cleanExit(); |
| 280 | 284 | } |
lib/compiler/resinator/main.zig+1-1| ... | ... | @@ -212,7 +212,7 @@ pub fn main() !void { |
| 212 | 212 | try output_file.writeAll(full_input); |
| 213 | 213 | }, |
| 214 | 214 | .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 }); | |
| 216 | 216 | }, |
| 217 | 217 | } |
| 218 | 218 | return; |
lib/compiler/std-docs.zig+1-1| ... | ... | @@ -233,7 +233,7 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void { |
| 233 | 233 | .interface = std.Io.File.Reader.initInterface(&.{}), |
| 234 | 234 | .size = stat.size, |
| 235 | 235 | }; |
| 236 | try archiver.writeFile(entry.path, &file_reader, stat.mtime); | |
| 236 | try archiver.writeFile(io, entry.path, &file_reader, stat.mtime); | |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | { |
lib/std/Build/Cache.zig+6-30| ... | ... | @@ -1276,30 +1276,6 @@ pub const Manifest = struct { |
| 1276 | 1276 | } |
| 1277 | 1277 | }; |
| 1278 | 1278 | |
| 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. | |
| 1282 | pub 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. | |
| 1294 | pub 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 | ||
| 1303 | 1279 | fn hashFile(io: Io, file: Io.File, bin_digest: *[Hasher.mac_length]u8) Io.File.ReadPositionalError!void { |
| 1304 | 1280 | var buffer: [2048]u8 = undefined; |
| 1305 | 1281 | var hasher = hasher_init; |
| ... | ... | @@ -1338,7 +1314,7 @@ test "cache file and then recall it" { |
| 1338 | 1314 | const temp_file = "test.txt"; |
| 1339 | 1315 | const temp_manifest_dir = "temp_manifest_dir"; |
| 1340 | 1316 | |
| 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" }); | |
| 1342 | 1318 | |
| 1343 | 1319 | // Wait for file timestamps to tick |
| 1344 | 1320 | const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir); |
| ... | ... | @@ -1404,7 +1380,7 @@ test "check that changing a file makes cache fail" { |
| 1404 | 1380 | const original_temp_file_contents = "Hello, world!\n"; |
| 1405 | 1381 | const updated_temp_file_contents = "Hello, world; but updated!\n"; |
| 1406 | 1382 | |
| 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 }); | |
| 1408 | 1384 | |
| 1409 | 1385 | // Wait for file timestamps to tick |
| 1410 | 1386 | const initial_time = try testGetCurrentFileTimestamp(tmp.dir); |
| ... | ... | @@ -1441,7 +1417,7 @@ test "check that changing a file makes cache fail" { |
| 1441 | 1417 | try ch.writeManifest(); |
| 1442 | 1418 | } |
| 1443 | 1419 | |
| 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 }); | |
| 1445 | 1421 | |
| 1446 | 1422 | { |
| 1447 | 1423 | var ch = cache.obtain(); |
| ... | ... | @@ -1521,8 +1497,8 @@ test "Manifest with files added after initial hash work" { |
| 1521 | 1497 | const temp_file2 = "cache_hash_post_file_test2.txt"; |
| 1522 | 1498 | const temp_manifest_dir = "cache_hash_post_file_manifest_dir"; |
| 1523 | 1499 | |
| 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" }); | |
| 1526 | 1502 | |
| 1527 | 1503 | // Wait for file timestamps to tick |
| 1528 | 1504 | const initial_time = try testGetCurrentFileTimestamp(tmp.dir); |
| ... | ... | @@ -1573,7 +1549,7 @@ test "Manifest with files added after initial hash work" { |
| 1573 | 1549 | try testing.expect(mem.eql(u8, &digest1, &digest2)); |
| 1574 | 1550 | |
| 1575 | 1551 | // 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" }); | |
| 1577 | 1553 | |
| 1578 | 1554 | // Wait for file timestamps to tick |
| 1579 | 1555 | 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 { |
| 264 | 264 | }); |
| 265 | 265 | }; |
| 266 | 266 | |
| 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| { | |
| 268 | 268 | return step.fail("unable to write file '{f}{s}': {s}", .{ |
| 269 | 269 | b.cache_root, sub_path, @errorName(err), |
| 270 | 270 | }); |
lib/std/Build/Step/Run.zig+1-1| ... | ... | @@ -1482,7 +1482,7 @@ fn runCommand( |
| 1482 | 1482 | .leading => mem.trimStart(u8, stream.bytes.?, &std.ascii.whitespace), |
| 1483 | 1483 | .trailing => mem.trimEnd(u8, stream.bytes.?, &std.ascii.whitespace), |
| 1484 | 1484 | }; |
| 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| { | |
| 1486 | 1486 | return step.fail("unable to write file '{f}{s}': {s}", .{ |
| 1487 | 1487 | b.cache_root, sub_path, @errorName(err), |
| 1488 | 1488 | }); |
lib/std/Build/Step/UpdateSourceFiles.zig+1-1| ... | ... | @@ -84,7 +84,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 84 | 84 | } |
| 85 | 85 | switch (output_source_file.contents) { |
| 86 | 86 | .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| { | |
| 88 | 88 | return step.fail("unable to write file '{f}{s}': {t}", .{ |
| 89 | 89 | b.build_root, output_source_file.sub_path, err, |
| 90 | 90 | }); |
lib/std/Build/Step/WriteFile.zig+1-1| ... | ... | @@ -273,7 +273,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 273 | 273 | } |
| 274 | 274 | switch (file.contents) { |
| 275 | 275 | .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| { | |
| 277 | 277 | return step.fail("unable to write file '{f}{s}{c}{s}': {t}", .{ |
| 278 | 278 | b.cache_root, cache_path, fs.path.sep, file.sub_path, err, |
| 279 | 279 | }); |
lib/std/Build/WebServer.zig+1-1| ... | ... | @@ -523,7 +523,7 @@ pub fn serveTarFile(ws: *WebServer, request: *http.Server.Request, paths: []cons |
| 523 | 523 | if (cached_cwd_path == null) cached_cwd_path = try std.process.getCwdAlloc(gpa); |
| 524 | 524 | break :cwd cached_cwd_path.?; |
| 525 | 525 | }; |
| 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())); | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // intentionally not calling `archiver.finishPedantically` |
lib/std/debug.zig+2-2| ... | ... | @@ -1243,7 +1243,7 @@ test printLineFromFile { |
| 1243 | 1243 | { |
| 1244 | 1244 | const path = try join(gpa, &.{ test_dir_path, "one_line.zig" }); |
| 1245 | 1245 | 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" }); | |
| 1247 | 1247 | |
| 1248 | 1248 | try expectError(error.EndOfFile, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 })); |
| 1249 | 1249 | |
| ... | ... | @@ -1254,7 +1254,7 @@ test printLineFromFile { |
| 1254 | 1254 | { |
| 1255 | 1255 | const path = try fs.path.join(gpa, &.{ test_dir_path, "three_lines.zig" }); |
| 1256 | 1256 | defer gpa.free(path); |
| 1257 | try test_dir.dir.writeFile(.{ | |
| 1257 | try test_dir.dir.writeFile(io, .{ | |
| 1258 | 1258 | .sub_path = "three_lines.zig", |
| 1259 | 1259 | .data = |
| 1260 | 1260 | \\1 |
lib/std/fs/test.zig+28-20| ... | ... | @@ -184,7 +184,7 @@ test "Dir.readLink" { |
| 184 | 184 | fn impl(ctx: *TestContext) !void { |
| 185 | 185 | // Create some targets |
| 186 | 186 | 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" }); | |
| 188 | 188 | const dir_target_path = try ctx.transformPath("subdir"); |
| 189 | 189 | try ctx.dir.makeDir(dir_target_path); |
| 190 | 190 | |
| ... | ... | @@ -487,11 +487,13 @@ test "readLinkAbsolute" { |
| 487 | 487 | if (native_os == .wasi) return error.SkipZigTest; |
| 488 | 488 | if (native_os == .openbsd) return error.SkipZigTest; |
| 489 | 489 | |
| 490 | const io = testing.io; | |
| 491 | ||
| 490 | 492 | var tmp = tmpDir(.{}); |
| 491 | 493 | defer tmp.cleanup(); |
| 492 | 494 | |
| 493 | 495 | // 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" }); | |
| 495 | 497 | try tmp.dir.makeDir("subdir"); |
| 496 | 498 | |
| 497 | 499 | // Get base abs path |
| ... | ... | @@ -708,6 +710,7 @@ test "Dir.realpath smoke test" { |
| 708 | 710 | |
| 709 | 711 | try testWithAllSupportedPathTypes(struct { |
| 710 | 712 | fn impl(ctx: *TestContext) !void { |
| 713 | const io = ctx.io; | |
| 711 | 714 | const allocator = ctx.arena.allocator(); |
| 712 | 715 | const test_file_path = try ctx.transformPath("test_file"); |
| 713 | 716 | const test_dir_path = try ctx.transformPath("test_dir"); |
| ... | ... | @@ -720,7 +723,7 @@ test "Dir.realpath smoke test" { |
| 720 | 723 | try testing.expectError(error.FileNotFound, ctx.dir.realpath(test_dir_path, &buf)); |
| 721 | 724 | |
| 722 | 725 | // 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 = "" }); | |
| 724 | 727 | try ctx.dir.makeDir(test_dir_path); |
| 725 | 728 | |
| 726 | 729 | const base_path = try ctx.transformPath("."); |
| ... | ... | @@ -803,11 +806,12 @@ test "readFileAlloc" { |
| 803 | 806 | test "Dir.statFile" { |
| 804 | 807 | try testWithAllSupportedPathTypes(struct { |
| 805 | 808 | fn impl(ctx: *TestContext) !void { |
| 809 | const io = ctx.io; | |
| 806 | 810 | const test_file_name = try ctx.transformPath("test_file"); |
| 807 | 811 | |
| 808 | 812 | try testing.expectError(error.FileNotFound, ctx.dir.statFile(test_file_name)); |
| 809 | 813 | |
| 810 | try ctx.dir.writeFile(.{ .sub_path = test_file_name, .data = "" }); | |
| 814 | try ctx.dir.writeFile(io, .{ .sub_path = test_file_name, .data = "" }); | |
| 811 | 815 | |
| 812 | 816 | const stat = try ctx.dir.statFile(test_file_name); |
| 813 | 817 | try testing.expectEqual(File.Kind.file, stat.kind); |
| ... | ... | @@ -925,6 +929,7 @@ test "makeOpenPath parent dirs do not exist" { |
| 925 | 929 | test "deleteDir" { |
| 926 | 930 | try testWithAllSupportedPathTypes(struct { |
| 927 | 931 | fn impl(ctx: *TestContext) !void { |
| 932 | const io = ctx.io; | |
| 928 | 933 | const test_dir_path = try ctx.transformPath("test_dir"); |
| 929 | 934 | const test_file_path = try ctx.transformPath("test_dir" ++ fs.path.sep_str ++ "test_file"); |
| 930 | 935 | |
| ... | ... | @@ -933,7 +938,7 @@ test "deleteDir" { |
| 933 | 938 | |
| 934 | 939 | // deleting a non-empty directory |
| 935 | 940 | 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 = "" }); | |
| 937 | 942 | try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path)); |
| 938 | 943 | |
| 939 | 944 | // deleting an empty directory |
| ... | ... | @@ -1217,7 +1222,7 @@ test "deleteTree on a symlink" { |
| 1217 | 1222 | defer tmp.cleanup(); |
| 1218 | 1223 | |
| 1219 | 1224 | // Symlink to a file |
| 1220 | try tmp.dir.writeFile(.{ .sub_path = "file", .data = "" }); | |
| 1225 | try tmp.dir.writeFile(io, .{ .sub_path = "file", .data = "" }); | |
| 1221 | 1226 | try setupSymlink(tmp.dir, "file", "filelink", .{}); |
| 1222 | 1227 | |
| 1223 | 1228 | try tmp.dir.deleteTree("filelink"); |
| ... | ... | @@ -1241,11 +1246,11 @@ test "makePath, put some files in it, deleteTree" { |
| 1241 | 1246 | const dir_path = try ctx.transformPath("os_test_tmp"); |
| 1242 | 1247 | |
| 1243 | 1248 | 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, .{ | |
| 1245 | 1250 | .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }), |
| 1246 | 1251 | .data = "nonsense", |
| 1247 | 1252 | }); |
| 1248 | try ctx.dir.writeFile(.{ | |
| 1253 | try ctx.dir.writeFile(io, .{ | |
| 1249 | 1254 | .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }), |
| 1250 | 1255 | .data = "blah", |
| 1251 | 1256 | }); |
| ... | ... | @@ -1264,11 +1269,11 @@ test "makePath, put some files in it, deleteTreeMinStackSize" { |
| 1264 | 1269 | const dir_path = try ctx.transformPath("os_test_tmp"); |
| 1265 | 1270 | |
| 1266 | 1271 | 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, .{ | |
| 1268 | 1273 | .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }), |
| 1269 | 1274 | .data = "nonsense", |
| 1270 | 1275 | }); |
| 1271 | try ctx.dir.writeFile(.{ | |
| 1276 | try ctx.dir.writeFile(io, .{ | |
| 1272 | 1277 | .sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }), |
| 1273 | 1278 | .data = "blah", |
| 1274 | 1279 | }); |
| ... | ... | @@ -1298,7 +1303,7 @@ test "makePath but sub_path contains pre-existing file" { |
| 1298 | 1303 | defer tmp.cleanup(); |
| 1299 | 1304 | |
| 1300 | 1305 | 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 = "" }); | |
| 1302 | 1307 | |
| 1303 | 1308 | try testing.expectError(error.NotDir, tmp.dir.makePath(io, "foo/bar/baz")); |
| 1304 | 1309 | } |
| ... | ... | @@ -1400,7 +1405,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8) !vo |
| 1400 | 1405 | var maxed_dir = try iterable_dir.makeOpenPath(maxed_filename, .{}); |
| 1401 | 1406 | defer maxed_dir.close(io); |
| 1402 | 1407 | |
| 1403 | try maxed_dir.writeFile(.{ .sub_path = maxed_filename, .data = "" }); | |
| 1408 | try maxed_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" }); | |
| 1404 | 1409 | |
| 1405 | 1410 | var walker = try iterable_dir.walk(testing.allocator); |
| 1406 | 1411 | defer walker.deinit(); |
| ... | ... | @@ -1513,7 +1518,7 @@ test "setEndPos" { |
| 1513 | 1518 | defer tmp.cleanup(); |
| 1514 | 1519 | |
| 1515 | 1520 | 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" }); | |
| 1517 | 1522 | const f = try tmp.dir.openFile(io, file_name, .{ .mode = .read_write }); |
| 1518 | 1523 | defer f.close(io); |
| 1519 | 1524 | |
| ... | ... | @@ -1563,7 +1568,7 @@ test "access file" { |
| 1563 | 1568 | try ctx.dir.makePath(io, dir_path); |
| 1564 | 1569 | try testing.expectError(error.FileNotFound, ctx.dir.access(io, file_path, .{})); |
| 1565 | 1570 | |
| 1566 | try ctx.dir.writeFile(.{ .sub_path = file_path, .data = "" }); | |
| 1571 | try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" }); | |
| 1567 | 1572 | try ctx.dir.access(io, file_path, .{}); |
| 1568 | 1573 | try ctx.dir.deleteTree(dir_path); |
| 1569 | 1574 | } |
| ... | ... | @@ -1659,12 +1664,13 @@ test "sendfile with buffered data" { |
| 1659 | 1664 | test "copyFile" { |
| 1660 | 1665 | try testWithAllSupportedPathTypes(struct { |
| 1661 | 1666 | fn impl(ctx: *TestContext) !void { |
| 1667 | const io = ctx.io; | |
| 1662 | 1668 | const data = "u6wj+JmdF3qHsFPE BUlH2g4gJCmEz0PP"; |
| 1663 | 1669 | const src_file = try ctx.transformPath("tmp_test_copy_file.txt"); |
| 1664 | 1670 | const dest_file = try ctx.transformPath("tmp_test_copy_file2.txt"); |
| 1665 | 1671 | const dest_file2 = try ctx.transformPath("tmp_test_copy_file3.txt"); |
| 1666 | 1672 | |
| 1667 | try ctx.dir.writeFile(.{ .sub_path = src_file, .data = data }); | |
| 1673 | try ctx.dir.writeFile(io, .{ .sub_path = src_file, .data = data }); | |
| 1668 | 1674 | defer ctx.dir.deleteFile(src_file) catch {}; |
| 1669 | 1675 | |
| 1670 | 1676 | try ctx.dir.copyFile(src_file, ctx.dir, dest_file, .{}); |
| ... | ... | @@ -2050,7 +2056,7 @@ test "'.' and '..' in Io.Dir functions" { |
| 2050 | 2056 | renamed_file.close(io); |
| 2051 | 2057 | try ctx.dir.deleteFile(rename_path); |
| 2052 | 2058 | |
| 2053 | try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" }); | |
| 2059 | try ctx.dir.writeFile(io, .{ .sub_path = update_path, .data = "something" }); | |
| 2054 | 2060 | var dir = ctx.dir; |
| 2055 | 2061 | const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{}); |
| 2056 | 2062 | try testing.expectEqual(Io.Dir.PrevStatus.stale, prev_status); |
| ... | ... | @@ -2187,7 +2193,7 @@ test "invalid UTF-8/WTF-8 paths" { |
| 2187 | 2193 | try testing.expectError(expected_err, ctx.dir.deleteTree(invalid_path)); |
| 2188 | 2194 | try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path)); |
| 2189 | 2195 | |
| 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 = "" })); | |
| 2191 | 2197 | |
| 2192 | 2198 | try testing.expectError(expected_err, ctx.dir.access(invalid_path, .{})); |
| 2193 | 2199 | |
| ... | ... | @@ -2304,7 +2310,7 @@ test "seekBy" { |
| 2304 | 2310 | var tmp_dir = testing.tmpDir(.{}); |
| 2305 | 2311 | defer tmp_dir.cleanup(); |
| 2306 | 2312 | |
| 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" }); | |
| 2308 | 2314 | const f = try tmp_dir.dir.openFile(io, "blah.txt", .{ .mode = .read_only }); |
| 2309 | 2315 | defer f.close(io); |
| 2310 | 2316 | var reader = f.readerStreaming(io, &.{}); |
| ... | ... | @@ -2350,7 +2356,7 @@ test "File.Writer sendfile with buffered contents" { |
| 2350 | 2356 | defer tmp_dir.cleanup(); |
| 2351 | 2357 | |
| 2352 | 2358 | { |
| 2353 | try tmp_dir.dir.writeFile(.{ .sub_path = "a", .data = "bcd" }); | |
| 2359 | try tmp_dir.dir.writeFile(io, .{ .sub_path = "a", .data = "bcd" }); | |
| 2354 | 2360 | const in = try tmp_dir.dir.openFile(io, "a", .{}); |
| 2355 | 2361 | defer in.close(io); |
| 2356 | 2362 | const out = try tmp_dir.dir.createFile(io, "b", .{}); |
| ... | ... | @@ -2391,11 +2397,13 @@ fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void { |
| 2391 | 2397 | } |
| 2392 | 2398 | |
| 2393 | 2399 | test "readlinkat" { |
| 2400 | const io = testing.io; | |
| 2401 | ||
| 2394 | 2402 | var tmp = tmpDir(.{}); |
| 2395 | 2403 | defer tmp.cleanup(); |
| 2396 | 2404 | |
| 2397 | 2405 | // 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" }); | |
| 2399 | 2407 | |
| 2400 | 2408 | // create a symbolic link |
| 2401 | 2409 | if (native_os == .windows) { |
lib/std/posix/test.zig+1-1| ... | ... | @@ -145,7 +145,7 @@ test "linkat with different directories" { |
| 145 | 145 | const subdir = try tmp.dir.makeOpenPath("subdir", .{}); |
| 146 | 146 | |
| 147 | 147 | 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" }); | |
| 149 | 149 | |
| 150 | 150 | // Test 1: link from file in subdir back up to target in parent directory |
| 151 | 151 | 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( |
| 5715 | 5715 | const out_h_sub_path = tmp_sub_path ++ fs.path.sep_str ++ cimport_basename; |
| 5716 | 5716 | const out_h_path = try comp.dirs.local_cache.join(arena, &.{out_h_sub_path}); |
| 5717 | 5717 | 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 }); | |
| 5719 | 5719 | break :path out_h_path; |
| 5720 | 5720 | }, |
| 5721 | 5721 | .path => |p| p, |
| ... | ... | @@ -6572,7 +6572,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 6572 | 6572 | resource_id, resource_type, fmtRcEscape(src_path), |
| 6573 | 6573 | }); |
| 6574 | 6574 | |
| 6575 | try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input }); | |
| 6575 | try o_dir.writeFile(io, .{ .sub_path = rc_basename, .data = input }); | |
| 6576 | 6576 | |
| 6577 | 6577 | var argv = std.array_list.Managed([]const u8).init(comp.gpa); |
| 6578 | 6578 | defer argv.deinit(); |
src/libs/freebsd.zig+2-2| ... | ... | @@ -520,7 +520,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 520 | 520 | for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| { |
| 521 | 521 | try map_contents.print("FBSD_{d}.{d} {{ }};\n", .{ ver.major, ver.minor }); |
| 522 | 522 | } |
| 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 }); | |
| 524 | 524 | map_contents.deinit(); |
| 525 | 525 | } |
| 526 | 526 | |
| ... | ... | @@ -974,7 +974,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 974 | 974 | |
| 975 | 975 | var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "stdthreads", etc. |
| 976 | 976 | 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 }); | |
| 978 | 978 | try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); |
| 979 | 979 | } |
| 980 | 980 |
src/libs/glibc.zig+2-2| ... | ... | @@ -759,7 +759,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 759 | 759 | try map_contents.print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch }); |
| 760 | 760 | } |
| 761 | 761 | } |
| 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 }); | |
| 763 | 763 | map_contents.deinit(); // The most recent allocation of an arena can be freed :) |
| 764 | 764 | } |
| 765 | 765 | |
| ... | ... | @@ -1118,7 +1118,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 1118 | 1118 | |
| 1119 | 1119 | var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc. |
| 1120 | 1120 | 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 }); | |
| 1122 | 1122 | try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); |
| 1123 | 1123 | } |
| 1124 | 1124 |
src/libs/netbsd.zig+1-1| ... | ... | @@ -628,7 +628,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 628 | 628 | |
| 629 | 629 | var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc. |
| 630 | 630 | 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 }); | |
| 632 | 632 | try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); |
| 633 | 633 | } |
| 634 | 634 |
src/main.zig+3-3| ... | ... | @@ -7164,7 +7164,7 @@ fn cmdFetch( |
| 7164 | 7164 | try ast.render(gpa, &aw.writer, fixups); |
| 7165 | 7165 | const rendered = aw.written(); |
| 7166 | 7166 | |
| 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| { | |
| 7168 | 7168 | fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err }); |
| 7169 | 7169 | }; |
| 7170 | 7170 | |
| ... | ... | @@ -7207,7 +7207,7 @@ fn createDependenciesModule( |
| 7207 | 7207 | { |
| 7208 | 7208 | var tmp_dir = try dirs.local_cache.handle.makeOpenPath(tmp_dir_sub_path, .{}); |
| 7209 | 7209 | 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 }); | |
| 7211 | 7211 | } |
| 7212 | 7212 | |
| 7213 | 7213 | var hh: Cache.HashHelper = .{}; |
| ... | ... | @@ -7438,7 +7438,7 @@ const Templates = struct { |
| 7438 | 7438 | i += 1; |
| 7439 | 7439 | } |
| 7440 | 7440 | |
| 7441 | return out_dir.writeFile(.{ | |
| 7441 | return out_dir.writeFile(io, .{ | |
| 7442 | 7442 | .sub_path = template_path, |
| 7443 | 7443 | .data = templates.buffer.items, |
| 7444 | 7444 | .flags = .{ .exclusive = true }, |