| author | |
| committer | |
| log | f53248a40936ebc9aaf75ddbd16e67ebec05ab84 |
| tree | af6a1a4fa4d3ff09dae241922a8f7c37cde43681 |
| parent | 916998315967f73c91e682e9ea05dd3232818654 |
72 files changed, 398 insertions(+), 377 deletions(-)
lib/compiler/aro/aro/Compilation.zig+4-4| ... | ... | @@ -2253,7 +2253,7 @@ test "addSourceFromBuffer" { |
| 2253 | 2253 | var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); |
| 2254 | 2254 | defer arena.deinit(); |
| 2255 | 2255 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 2256 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, &diagnostics, std.fs.cwd()); | |
| 2256 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 2257 | 2257 | defer comp.deinit(); |
| 2258 | 2258 | |
| 2259 | 2259 | const source = try comp.addSourceFromBuffer("path", str); |
| ... | ... | @@ -2267,7 +2267,7 @@ test "addSourceFromBuffer" { |
| 2267 | 2267 | var arena: std.heap.ArenaAllocator = .init(allocator); |
| 2268 | 2268 | defer arena.deinit(); |
| 2269 | 2269 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 2270 | var comp = Compilation.init(allocator, arena.allocator(), std.testing.io, &diagnostics, std.fs.cwd()); | |
| 2270 | var comp = Compilation.init(allocator, arena.allocator(), std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 2271 | 2271 | defer comp.deinit(); |
| 2272 | 2272 | |
| 2273 | 2273 | _ = try comp.addSourceFromBuffer("path", "spliced\\\nbuffer\n"); |
| ... | ... | @@ -2313,7 +2313,7 @@ test "addSourceFromBuffer - exhaustive check for carriage return elimination" { |
| 2313 | 2313 | var buf: [alphabet.len]u8 = @splat(alphabet[0]); |
| 2314 | 2314 | |
| 2315 | 2315 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 2316 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, &diagnostics, std.fs.cwd()); | |
| 2316 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 2317 | 2317 | defer comp.deinit(); |
| 2318 | 2318 | |
| 2319 | 2319 | var source_count: u32 = 0; |
| ... | ... | @@ -2341,7 +2341,7 @@ test "ignore BOM at beginning of file" { |
| 2341 | 2341 | const Test = struct { |
| 2342 | 2342 | fn run(arena: Allocator, buf: []const u8) !void { |
| 2343 | 2343 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 2344 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, &diagnostics, std.fs.cwd()); | |
| 2344 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 2345 | 2345 | defer comp.deinit(); |
| 2346 | 2346 | |
| 2347 | 2347 | const source = try comp.addSourceFromBuffer("file.c", buf); |
lib/compiler/aro/aro/Driver.zig+5-5| ... | ... | @@ -1327,7 +1327,7 @@ fn processSource( |
| 1327 | 1327 | const dep_file_name = try d.getDepFileName(source, writer_buf[0..std.fs.max_name_bytes]); |
| 1328 | 1328 | |
| 1329 | 1329 | const file = if (dep_file_name) |path| |
| 1330 | d.comp.cwd.createFile(path, .{}) catch |er| | |
| 1330 | d.comp.cwd.createFile(io, path, .{}) catch |er| | |
| 1331 | 1331 | return d.fatal("unable to create dependency file '{s}': {s}", .{ path, errorDescription(er) }) |
| 1332 | 1332 | else |
| 1333 | 1333 | Io.File.stdout(); |
| ... | ... | @@ -1352,7 +1352,7 @@ fn processSource( |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | const file = if (d.output_name) |some| |
| 1355 | d.comp.cwd.createFile(some, .{}) catch |er| | |
| 1355 | d.comp.cwd.createFile(io, some, .{}) catch |er| | |
| 1356 | 1356 | return d.fatal("unable to create output file '{s}': {s}", .{ some, errorDescription(er) }) |
| 1357 | 1357 | else |
| 1358 | 1358 | Io.File.stdout(); |
| ... | ... | @@ -1405,7 +1405,7 @@ fn processSource( |
| 1405 | 1405 | defer assembly.deinit(gpa); |
| 1406 | 1406 | |
| 1407 | 1407 | if (d.only_preprocess_and_compile) { |
| 1408 | const out_file = d.comp.cwd.createFile(out_file_name, .{}) catch |er| | |
| 1408 | const out_file = d.comp.cwd.createFile(io, out_file_name, .{}) catch |er| | |
| 1409 | 1409 | return d.fatal("unable to create output file '{s}': {s}", .{ out_file_name, errorDescription(er) }); |
| 1410 | 1410 | defer out_file.close(io); |
| 1411 | 1411 | |
| ... | ... | @@ -1419,7 +1419,7 @@ fn processSource( |
| 1419 | 1419 | // then assemble to out_file_name |
| 1420 | 1420 | var assembly_name_buf: [std.fs.max_name_bytes]u8 = undefined; |
| 1421 | 1421 | const assembly_out_file_name = try d.getRandomFilename(&assembly_name_buf, ".s"); |
| 1422 | const out_file = d.comp.cwd.createFile(assembly_out_file_name, .{}) catch |er| | |
| 1422 | const out_file = d.comp.cwd.createFile(io, assembly_out_file_name, .{}) catch |er| | |
| 1423 | 1423 | return d.fatal("unable to create output file '{s}': {s}", .{ assembly_out_file_name, errorDescription(er) }); |
| 1424 | 1424 | defer out_file.close(io); |
| 1425 | 1425 | assembly.writeToFile(out_file) catch |er| |
| ... | ... | @@ -1455,7 +1455,7 @@ fn processSource( |
| 1455 | 1455 | }; |
| 1456 | 1456 | defer obj.deinit(); |
| 1457 | 1457 | |
| 1458 | const out_file = d.comp.cwd.createFile(out_file_name, .{}) catch |er| | |
| 1458 | const out_file = d.comp.cwd.createFile(io, out_file_name, .{}) catch |er| | |
| 1459 | 1459 | return d.fatal("unable to create output file '{s}': {s}", .{ out_file_name, errorDescription(er) }); |
| 1460 | 1460 | defer out_file.close(io); |
| 1461 | 1461 |
lib/compiler/aro/aro/Parser.zig+14-13| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const Allocator = mem.Allocator; |
| 4 | 5 | const assert = std.debug.assert; |
| ... | ... | @@ -211,7 +212,7 @@ fn checkIdentifierCodepointWarnings(p: *Parser, codepoint: u21, loc: Source.Loca |
| 211 | 212 | |
| 212 | 213 | const prev_total = p.diagnostics.total; |
| 213 | 214 | var sf = std.heap.stackFallback(1024, p.comp.gpa); |
| 214 | var allocating: std.Io.Writer.Allocating = .init(sf.get()); | |
| 215 | var allocating: Io.Writer.Allocating = .init(sf.get()); | |
| 215 | 216 | defer allocating.deinit(); |
| 216 | 217 | |
| 217 | 218 | if (!char_info.isC99IdChar(codepoint)) { |
| ... | ... | @@ -425,7 +426,7 @@ pub fn err(p: *Parser, tok_i: TokenIndex, diagnostic: Diagnostic, args: anytype) |
| 425 | 426 | if (p.diagnostics.effectiveKind(diagnostic) == .off) return; |
| 426 | 427 | |
| 427 | 428 | var sf = std.heap.stackFallback(1024, p.comp.gpa); |
| 428 | var allocating: std.Io.Writer.Allocating = .init(sf.get()); | |
| 429 | var allocating: Io.Writer.Allocating = .init(sf.get()); | |
| 429 | 430 | defer allocating.deinit(); |
| 430 | 431 | |
| 431 | 432 | p.formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory; |
| ... | ... | @@ -447,7 +448,7 @@ pub fn err(p: *Parser, tok_i: TokenIndex, diagnostic: Diagnostic, args: anytype) |
| 447 | 448 | }, p.pp.expansionSlice(tok_i), true); |
| 448 | 449 | } |
| 449 | 450 | |
| 450 | fn formatArgs(p: *Parser, w: *std.Io.Writer, fmt: []const u8, args: anytype) !void { | |
| 451 | fn formatArgs(p: *Parser, w: *Io.Writer, fmt: []const u8, args: anytype) !void { | |
| 451 | 452 | var i: usize = 0; |
| 452 | 453 | inline for (std.meta.fields(@TypeOf(args))) |arg_info| { |
| 453 | 454 | const arg = @field(args, arg_info.name); |
| ... | ... | @@ -476,13 +477,13 @@ fn formatArgs(p: *Parser, w: *std.Io.Writer, fmt: []const u8, args: anytype) !vo |
| 476 | 477 | try w.writeAll(fmt[i..]); |
| 477 | 478 | } |
| 478 | 479 | |
| 479 | fn formatTokenId(w: *std.Io.Writer, fmt: []const u8, tok_id: Tree.Token.Id) !usize { | |
| 480 | fn formatTokenId(w: *Io.Writer, fmt: []const u8, tok_id: Tree.Token.Id) !usize { | |
| 480 | 481 | const i = Diagnostics.templateIndex(w, fmt, "{tok_id}"); |
| 481 | 482 | try w.writeAll(tok_id.symbol()); |
| 482 | 483 | return i; |
| 483 | 484 | } |
| 484 | 485 | |
| 485 | fn formatQualType(p: *Parser, w: *std.Io.Writer, fmt: []const u8, qt: QualType) !usize { | |
| 486 | fn formatQualType(p: *Parser, w: *Io.Writer, fmt: []const u8, qt: QualType) !usize { | |
| 486 | 487 | const i = Diagnostics.templateIndex(w, fmt, "{qt}"); |
| 487 | 488 | try w.writeByte('\''); |
| 488 | 489 | try qt.print(p.comp, w); |
| ... | ... | @@ -501,7 +502,7 @@ fn formatQualType(p: *Parser, w: *std.Io.Writer, fmt: []const u8, qt: QualType) |
| 501 | 502 | return i; |
| 502 | 503 | } |
| 503 | 504 | |
| 504 | fn formatResult(p: *Parser, w: *std.Io.Writer, fmt: []const u8, res: Result) !usize { | |
| 505 | fn formatResult(p: *Parser, w: *Io.Writer, fmt: []const u8, res: Result) !usize { | |
| 505 | 506 | const i = Diagnostics.templateIndex(w, fmt, "{value}"); |
| 506 | 507 | switch (res.val.opt_ref) { |
| 507 | 508 | .none => try w.writeAll("(none)"), |
| ... | ... | @@ -524,7 +525,7 @@ const Normalized = struct { |
| 524 | 525 | return .{ .str = str }; |
| 525 | 526 | } |
| 526 | 527 | |
| 527 | pub fn format(ctx: Normalized, w: *std.Io.Writer, fmt: []const u8) !usize { | |
| 528 | pub fn format(ctx: Normalized, w: *Io.Writer, fmt: []const u8) !usize { | |
| 528 | 529 | const i = Diagnostics.templateIndex(w, fmt, "{normalized}"); |
| 529 | 530 | var it: std.unicode.Utf8Iterator = .{ |
| 530 | 531 | .bytes = ctx.str, |
| ... | ... | @@ -558,7 +559,7 @@ const Codepoint = struct { |
| 558 | 559 | return .{ .codepoint = codepoint }; |
| 559 | 560 | } |
| 560 | 561 | |
| 561 | pub fn format(ctx: Codepoint, w: *std.Io.Writer, fmt: []const u8) !usize { | |
| 562 | pub fn format(ctx: Codepoint, w: *Io.Writer, fmt: []const u8) !usize { | |
| 562 | 563 | const i = Diagnostics.templateIndex(w, fmt, "{codepoint}"); |
| 563 | 564 | try w.print("{X:0>4}", .{ctx.codepoint}); |
| 564 | 565 | return i; |
| ... | ... | @@ -572,7 +573,7 @@ const Escaped = struct { |
| 572 | 573 | return .{ .str = str }; |
| 573 | 574 | } |
| 574 | 575 | |
| 575 | pub fn format(ctx: Escaped, w: *std.Io.Writer, fmt: []const u8) !usize { | |
| 576 | pub fn format(ctx: Escaped, w: *Io.Writer, fmt: []const u8) !usize { | |
| 576 | 577 | const i = Diagnostics.templateIndex(w, fmt, "{s}"); |
| 577 | 578 | try std.zig.stringEscape(ctx.str, w); |
| 578 | 579 | return i; |
| ... | ... | @@ -1453,7 +1454,7 @@ fn decl(p: *Parser) Error!bool { |
| 1453 | 1454 | return true; |
| 1454 | 1455 | } |
| 1455 | 1456 | |
| 1456 | fn staticAssertMessage(p: *Parser, cond_node: Node.Index, maybe_message: ?Result, allocating: *std.Io.Writer.Allocating) !?[]const u8 { | |
| 1457 | fn staticAssertMessage(p: *Parser, cond_node: Node.Index, maybe_message: ?Result, allocating: *Io.Writer.Allocating) !?[]const u8 { | |
| 1457 | 1458 | const w = &allocating.writer; |
| 1458 | 1459 | |
| 1459 | 1460 | const cond = cond_node.get(&p.tree); |
| ... | ... | @@ -1526,7 +1527,7 @@ fn staticAssert(p: *Parser) Error!bool { |
| 1526 | 1527 | } else { |
| 1527 | 1528 | if (!res.val.toBool(p.comp)) { |
| 1528 | 1529 | var sf = std.heap.stackFallback(1024, gpa); |
| 1529 | var allocating: std.Io.Writer.Allocating = .init(sf.get()); | |
| 1530 | var allocating: Io.Writer.Allocating = .init(sf.get()); | |
| 1530 | 1531 | defer allocating.deinit(); |
| 1531 | 1532 | |
| 1532 | 1533 | if (p.staticAssertMessage(res_node, str, &allocating) catch return error.OutOfMemory) |message| { |
| ... | ... | @@ -9719,7 +9720,7 @@ fn primaryExpr(p: *Parser) Error!?Result { |
| 9719 | 9720 | qt = some.qt; |
| 9720 | 9721 | } else if (p.func.qt) |func_qt| { |
| 9721 | 9722 | var sf = std.heap.stackFallback(1024, gpa); |
| 9722 | var allocating: std.Io.Writer.Allocating = .init(sf.get()); | |
| 9723 | var allocating: Io.Writer.Allocating = .init(sf.get()); | |
| 9723 | 9724 | defer allocating.deinit(); |
| 9724 | 9725 | |
| 9725 | 9726 | func_qt.printNamed(p.tokSlice(p.func.name), p.comp, &allocating.writer) catch return error.OutOfMemory; |
| ... | ... | @@ -10608,7 +10609,7 @@ test "Node locations" { |
| 10608 | 10609 | const arena = arena_state.allocator(); |
| 10609 | 10610 | |
| 10610 | 10611 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 10611 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, &diagnostics, std.fs.cwd()); | |
| 10612 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 10612 | 10613 | defer comp.deinit(); |
| 10613 | 10614 | |
| 10614 | 10615 | const file = try comp.addSourceFromBuffer("file.c", |
lib/compiler/aro/aro/Preprocessor.zig+3-3| ... | ... | @@ -3900,7 +3900,7 @@ test "Preserve pragma tokens sometimes" { |
| 3900 | 3900 | defer arena.deinit(); |
| 3901 | 3901 | |
| 3902 | 3902 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 3903 | var comp = Compilation.init(gpa, arena.allocator(), std.testing.io, &diagnostics, std.fs.cwd()); | |
| 3903 | var comp = Compilation.init(gpa, arena.allocator(), std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 3904 | 3904 | defer comp.deinit(); |
| 3905 | 3905 | |
| 3906 | 3906 | try comp.addDefaultPragmaHandlers(); |
| ... | ... | @@ -3967,7 +3967,7 @@ test "destringify" { |
| 3967 | 3967 | var arena: std.heap.ArenaAllocator = .init(gpa); |
| 3968 | 3968 | defer arena.deinit(); |
| 3969 | 3969 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 3970 | var comp = Compilation.init(gpa, arena.allocator(), std.testing.io, &diagnostics, std.fs.cwd()); | |
| 3970 | var comp = Compilation.init(gpa, arena.allocator(), std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 3971 | 3971 | defer comp.deinit(); |
| 3972 | 3972 | var pp = Preprocessor.init(&comp, .default); |
| 3973 | 3973 | defer pp.deinit(); |
| ... | ... | @@ -4030,7 +4030,7 @@ test "Include guards" { |
| 4030 | 4030 | const arena = arena_state.allocator(); |
| 4031 | 4031 | |
| 4032 | 4032 | var diagnostics: Diagnostics = .{ .output = .ignore }; |
| 4033 | var comp = Compilation.init(gpa, arena, std.testing.io, &diagnostics, std.fs.cwd()); | |
| 4033 | var comp = Compilation.init(gpa, arena, std.testing.io, &diagnostics, Io.Dir.cwd()); | |
| 4034 | 4034 | defer comp.deinit(); |
| 4035 | 4035 | var pp = Preprocessor.init(&comp, .default); |
| 4036 | 4036 | defer pp.deinit(); |
lib/compiler/aro/aro/Tokenizer.zig+3-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | |
| 4 | 5 | const Compilation = @import("Compilation.zig"); |
| ... | ... | @@ -2326,7 +2327,7 @@ test "Tokenizer fuzz test" { |
| 2326 | 2327 | fn testOne(_: @This(), input_bytes: []const u8) anyerror!void { |
| 2327 | 2328 | var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); |
| 2328 | 2329 | defer arena.deinit(); |
| 2329 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, undefined, std.fs.cwd()); | |
| 2330 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, undefined, Io.Dir.cwd()); | |
| 2330 | 2331 | defer comp.deinit(); |
| 2331 | 2332 | |
| 2332 | 2333 | const source = try comp.addSourceFromBuffer("fuzz.c", input_bytes); |
| ... | ... | @@ -2351,7 +2352,7 @@ test "Tokenizer fuzz test" { |
| 2351 | 2352 | fn expectTokensExtra(contents: []const u8, expected_tokens: []const Token.Id, langopts: ?LangOpts) !void { |
| 2352 | 2353 | var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); |
| 2353 | 2354 | defer arena.deinit(); |
| 2354 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, undefined, std.fs.cwd()); | |
| 2355 | var comp = Compilation.init(std.testing.allocator, arena.allocator(), std.testing.io, undefined, Io.Dir.cwd()); | |
| 2355 | 2356 | defer comp.deinit(); |
| 2356 | 2357 | if (langopts) |provided| { |
| 2357 | 2358 | comp.langopts = provided; |
lib/compiler/aro/aro/Value.zig+6-5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const assert = std.debug.assert; |
| 3 | 4 | const BigIntConst = std.math.big.int.Const; |
| 4 | 5 | const BigIntMutable = std.math.big.int.Mutable; |
| ... | ... | @@ -80,7 +81,7 @@ test "minUnsignedBits" { |
| 80 | 81 | defer arena_state.deinit(); |
| 81 | 82 | const arena = arena_state.allocator(); |
| 82 | 83 | |
| 83 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, undefined, std.fs.cwd()); | |
| 84 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, undefined, Io.Dir.cwd()); | |
| 84 | 85 | defer comp.deinit(); |
| 85 | 86 | const target_query = try std.Target.Query.parse(.{ .arch_os_abi = "x86_64-linux-gnu" }); |
| 86 | 87 | comp.target = .fromZigTarget(try std.zig.system.resolveTargetQuery(std.testing.io, target_query)); |
| ... | ... | @@ -119,7 +120,7 @@ test "minSignedBits" { |
| 119 | 120 | defer arena_state.deinit(); |
| 120 | 121 | const arena = arena_state.allocator(); |
| 121 | 122 | |
| 122 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, undefined, std.fs.cwd()); | |
| 123 | var comp = Compilation.init(std.testing.allocator, arena, std.testing.io, undefined, Io.Dir.cwd()); | |
| 123 | 124 | defer comp.deinit(); |
| 124 | 125 | const target_query = try std.Target.Query.parse(.{ .arch_os_abi = "x86_64-linux-gnu" }); |
| 125 | 126 | comp.target = .fromZigTarget(try std.zig.system.resolveTargetQuery(std.testing.io, target_query)); |
| ... | ... | @@ -1080,7 +1081,7 @@ const NestedPrint = union(enum) { |
| 1080 | 1081 | }, |
| 1081 | 1082 | }; |
| 1082 | 1083 | |
| 1083 | pub fn printPointer(offset: Value, base: []const u8, comp: *const Compilation, w: *std.Io.Writer) std.Io.Writer.Error!void { | |
| 1084 | pub fn printPointer(offset: Value, base: []const u8, comp: *const Compilation, w: *Io.Writer) Io.Writer.Error!void { | |
| 1084 | 1085 | try w.writeByte('&'); |
| 1085 | 1086 | try w.writeAll(base); |
| 1086 | 1087 | if (!offset.isZero(comp)) { |
| ... | ... | @@ -1089,7 +1090,7 @@ pub fn printPointer(offset: Value, base: []const u8, comp: *const Compilation, w |
| 1089 | 1090 | } |
| 1090 | 1091 | } |
| 1091 | 1092 | |
| 1092 | pub fn print(v: Value, qt: QualType, comp: *const Compilation, w: *std.Io.Writer) std.Io.Writer.Error!?NestedPrint { | |
| 1093 | pub fn print(v: Value, qt: QualType, comp: *const Compilation, w: *Io.Writer) Io.Writer.Error!?NestedPrint { | |
| 1093 | 1094 | if (qt.is(comp, .bool)) { |
| 1094 | 1095 | try w.writeAll(if (v.isZero(comp)) "false" else "true"); |
| 1095 | 1096 | return null; |
| ... | ... | @@ -1116,7 +1117,7 @@ pub fn print(v: Value, qt: QualType, comp: *const Compilation, w: *std.Io.Writer |
| 1116 | 1117 | return null; |
| 1117 | 1118 | } |
| 1118 | 1119 | |
| 1119 | pub fn printString(bytes: []const u8, qt: QualType, comp: *const Compilation, w: *std.Io.Writer) std.Io.Writer.Error!void { | |
| 1120 | pub fn printString(bytes: []const u8, qt: QualType, comp: *const Compilation, w: *Io.Writer) Io.Writer.Error!void { | |
| 1120 | 1121 | const size: Compilation.CharUnitSize = @enumFromInt(qt.childType(comp).sizeof(comp)); |
| 1121 | 1122 | const without_null = bytes[0 .. bytes.len - @intFromEnum(size)]; |
| 1122 | 1123 | try w.writeByte('"'); |
lib/compiler/aro/main.zig+1-1| ... | ... | @@ -59,7 +59,7 @@ pub fn main() u8 { |
| 59 | 59 | } }, |
| 60 | 60 | }; |
| 61 | 61 | |
| 62 | var comp = Compilation.initDefault(gpa, arena, io, &diagnostics, std.fs.cwd()) catch |er| switch (er) { | |
| 62 | var comp = Compilation.initDefault(gpa, arena, io, &diagnostics, Io.Dir.cwd()) catch |er| switch (er) { | |
| 63 | 63 | error.OutOfMemory => { |
| 64 | 64 | std.debug.print("out of memory\n", .{}); |
| 65 | 65 | if (fast_exit) process.exit(1); |
lib/compiler/objcopy.zig+2-2| ... | ... | @@ -152,7 +152,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 152 | 152 | defer threaded.deinit(); |
| 153 | 153 | const io = threaded.io(); |
| 154 | 154 | |
| 155 | const input_file = fs.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err }); | |
| 155 | const input_file = Io.Dir.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err }); | |
| 156 | 156 | defer input_file.close(io); |
| 157 | 157 | |
| 158 | 158 | const stat = input_file.stat() catch |err| fatal("failed to stat {s}: {t}", .{ input, err }); |
| ... | ... | @@ -180,7 +180,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 180 | 180 | |
| 181 | 181 | const mode = if (out_fmt != .elf or only_keep_debug) Io.File.default_mode else stat.mode; |
| 182 | 182 | |
| 183 | var output_file = try fs.cwd().createFile(output, .{ .mode = mode }); | |
| 183 | var output_file = try Io.Dir.cwd().createFile(io, output, .{ .mode = mode }); | |
| 184 | 184 | defer output_file.close(io); |
| 185 | 185 | |
| 186 | 186 | var out = output_file.writer(&output_buffer); |
lib/compiler/reduce.zig+3-3| ... | ... | @@ -233,7 +233,7 @@ pub fn main() !void { |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() }); | |
| 236 | try Io.Dir.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() }); | |
| 237 | 237 | // std.debug.print("trying this code:\n{s}\n", .{rendered.items}); |
| 238 | 238 | |
| 239 | 239 | const interestingness = try runCheck(arena, interestingness_argv.items); |
| ... | ... | @@ -274,7 +274,7 @@ pub fn main() !void { |
| 274 | 274 | fixups.clearRetainingCapacity(); |
| 275 | 275 | rendered.clearRetainingCapacity(); |
| 276 | 276 | try tree.render(gpa, &rendered.writer, fixups); |
| 277 | try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() }); | |
| 277 | try Io.Dir.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() }); | |
| 278 | 278 | |
| 279 | 279 | return std.process.cleanExit(); |
| 280 | 280 | } |
| ... | ... | @@ -398,7 +398,7 @@ fn transformationsToFixups( |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | fn parse(gpa: Allocator, file_path: []const u8) !Ast { |
| 401 | const source_code = std.fs.cwd().readFileAllocOptions( | |
| 401 | const source_code = Io.Dir.cwd().readFileAllocOptions( | |
| 402 | 402 | file_path, |
| 403 | 403 | gpa, |
| 404 | 404 | .limited(std.math.maxInt(u32)), |
lib/compiler/resinator/cli.zig+1-1| ... | ... | @@ -2003,7 +2003,7 @@ test "maybeAppendRC" { |
| 2003 | 2003 | |
| 2004 | 2004 | // Create the file so that it's found. In this scenario, .rc should not get |
| 2005 | 2005 | // appended. |
| 2006 | var file = try tmp.dir.createFile("foo", .{}); | |
| 2006 | var file = try tmp.dir.createFile(io, "foo", .{}); | |
| 2007 | 2007 | file.close(io); |
| 2008 | 2008 | try options.maybeAppendRC(tmp.dir); |
| 2009 | 2009 | try std.testing.expectEqualStrings("foo", options.input_source.filename); |
lib/compiler/resinator/compile.zig+2-2| ... | ... | @@ -111,7 +111,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io |
| 111 | 111 | try search_dirs.append(allocator, .{ .dir = root_dir, .path = try allocator.dupe(u8, root_dir_path) }); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | // Re-open the passed in cwd since we want to be able to close it (std.fs.cwd() shouldn't be closed) | |
| 114 | // Re-open the passed in cwd since we want to be able to close it (Io.Dir.cwd() shouldn't be closed) | |
| 115 | 115 | const cwd_dir = options.cwd.openDir(".", .{}) catch |err| { |
| 116 | 116 | try options.diagnostics.append(.{ |
| 117 | 117 | .err = .failed_to_open_cwd, |
| ... | ... | @@ -406,7 +406,7 @@ pub const Compiler = struct { |
| 406 | 406 | // `/test.bin` relative to include paths and instead only treats it as |
| 407 | 407 | // an absolute path. |
| 408 | 408 | if (std.fs.path.isAbsolute(path)) { |
| 409 | const file = try utils.openFileNotDir(std.fs.cwd(), path, .{}); | |
| 409 | const file = try utils.openFileNotDir(Io.Dir.cwd(), path, .{}); | |
| 410 | 410 | errdefer file.close(io); |
| 411 | 411 | |
| 412 | 412 | if (self.dependencies) |dependencies| { |
lib/compiler/resinator/main.zig+11-11| ... | ... | @@ -67,7 +67,7 @@ pub fn main() !void { |
| 67 | 67 | }, |
| 68 | 68 | else => |e| return e, |
| 69 | 69 | }; |
| 70 | try options.maybeAppendRC(std.fs.cwd()); | |
| 70 | try options.maybeAppendRC(Io.Dir.cwd()); | |
| 71 | 71 | |
| 72 | 72 | if (!zig_integration) { |
| 73 | 73 | // print any warnings/notes |
| ... | ... | @@ -141,7 +141,7 @@ pub fn main() !void { |
| 141 | 141 | if (!zig_integration) std.debug.unlockStderrWriter(); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | var comp = aro.Compilation.init(aro_arena, aro_arena, io, &diagnostics, std.fs.cwd()); | |
| 144 | var comp = aro.Compilation.init(aro_arena, aro_arena, io, &diagnostics, Io.Dir.cwd()); | |
| 145 | 145 | defer comp.deinit(); |
| 146 | 146 | |
| 147 | 147 | var argv: std.ArrayList([]const u8) = .empty; |
| ... | ... | @@ -196,7 +196,7 @@ pub fn main() !void { |
| 196 | 196 | }; |
| 197 | 197 | }, |
| 198 | 198 | .filename => |input_filename| { |
| 199 | break :full_input std.fs.cwd().readFileAlloc(input_filename, gpa, .unlimited) catch |err| { | |
| 199 | break :full_input Io.Dir.cwd().readFileAlloc(input_filename, gpa, .unlimited) catch |err| { | |
| 200 | 200 | try error_handler.emitMessage(gpa, .err, "unable to read input file path '{s}': {s}", .{ input_filename, @errorName(err) }); |
| 201 | 201 | std.process.exit(1); |
| 202 | 202 | }; |
| ... | ... | @@ -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 std.fs.cwd().writeFile(.{ .sub_path = output_filename, .data = full_input }); | |
| 215 | try Io.Dir.cwd().writeFile(.{ .sub_path = output_filename, .data = full_input }); | |
| 216 | 216 | }, |
| 217 | 217 | } |
| 218 | 218 | return; |
| ... | ... | @@ -277,7 +277,7 @@ pub fn main() !void { |
| 277 | 277 | const output_buffered_stream = res_stream_writer.interface(); |
| 278 | 278 | |
| 279 | 279 | compile(gpa, io, final_input, output_buffered_stream, .{ |
| 280 | .cwd = std.fs.cwd(), | |
| 280 | .cwd = Io.Dir.cwd(), | |
| 281 | 281 | .diagnostics = &diagnostics, |
| 282 | 282 | .source_mappings = &mapping_results.mappings, |
| 283 | 283 | .dependencies = maybe_dependencies, |
| ... | ... | @@ -294,7 +294,7 @@ pub fn main() !void { |
| 294 | 294 | .warn_instead_of_error_on_invalid_code_page = options.warn_instead_of_error_on_invalid_code_page, |
| 295 | 295 | }) catch |err| switch (err) { |
| 296 | 296 | error.ParseError, error.CompileError => { |
| 297 | try error_handler.emitDiagnostics(gpa, std.fs.cwd(), final_input, &diagnostics, mapping_results.mappings); | |
| 297 | try error_handler.emitDiagnostics(gpa, Io.Dir.cwd(), final_input, &diagnostics, mapping_results.mappings); | |
| 298 | 298 | // Delete the output file on error |
| 299 | 299 | res_stream.cleanupAfterError(io); |
| 300 | 300 | std.process.exit(1); |
| ... | ... | @@ -306,12 +306,12 @@ pub fn main() !void { |
| 306 | 306 | |
| 307 | 307 | // print any warnings/notes |
| 308 | 308 | if (!zig_integration) { |
| 309 | diagnostics.renderToStdErr(std.fs.cwd(), final_input, mapping_results.mappings); | |
| 309 | diagnostics.renderToStdErr(Io.Dir.cwd(), final_input, mapping_results.mappings); | |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // write the depfile |
| 313 | 313 | if (options.depfile_path) |depfile_path| { |
| 314 | var depfile = std.fs.cwd().createFile(depfile_path, .{}) catch |err| { | |
| 314 | var depfile = Io.Dir.cwd().createFile(io, depfile_path, .{}) catch |err| { | |
| 315 | 315 | try error_handler.emitMessage(gpa, .err, "unable to create depfile '{s}': {s}", .{ depfile_path, @errorName(err) }); |
| 316 | 316 | std.process.exit(1); |
| 317 | 317 | }; |
| ... | ... | @@ -440,7 +440,7 @@ const IoStream = struct { |
| 440 | 440 | // Delete the output file on error |
| 441 | 441 | file.close(io); |
| 442 | 442 | // Failing to delete is not really a big deal, so swallow any errors |
| 443 | std.fs.cwd().deleteFile(self.name) catch {}; | |
| 443 | Io.Dir.cwd().deleteFile(self.name) catch {}; | |
| 444 | 444 | }, |
| 445 | 445 | .stdio, .memory, .closed => return, |
| 446 | 446 | } |
| ... | ... | @@ -457,8 +457,8 @@ const IoStream = struct { |
| 457 | 457 | switch (source) { |
| 458 | 458 | .filename => |filename| return .{ |
| 459 | 459 | .file = switch (io) { |
| 460 | .input => try openFileNotDir(std.fs.cwd(), filename, .{}), | |
| 461 | .output => try std.fs.cwd().createFile(filename, .{}), | |
| 460 | .input => try openFileNotDir(Io.Dir.cwd(), filename, .{}), | |
| 461 | .output => try Io.Dir.cwd().createFile(io, filename, .{}), | |
| 462 | 462 | }, |
| 463 | 463 | }, |
| 464 | 464 | .stdio => |file| return .{ .stdio = file }, |
lib/compiler/std-docs.zig+1-1| ... | ... | @@ -40,7 +40,7 @@ pub fn main() !void { |
| 40 | 40 | const zig_exe_path = argv.next().?; |
| 41 | 41 | const global_cache_path = argv.next().?; |
| 42 | 42 | |
| 43 | var lib_dir = try std.fs.cwd().openDir(zig_lib_directory, .{}); | |
| 43 | var lib_dir = try Io.Dir.cwd().openDir(zig_lib_directory, .{}); | |
| 44 | 44 | defer lib_dir.close(io); |
| 45 | 45 | |
| 46 | 46 | var listen_port: u16 = 0; |
lib/compiler/translate-c/main.zig+4-4| ... | ... | @@ -47,7 +47,7 @@ pub fn main() u8 { |
| 47 | 47 | }; |
| 48 | 48 | defer diagnostics.deinit(); |
| 49 | 49 | |
| 50 | var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, std.fs.cwd()) catch |err| switch (err) { | |
| 50 | var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, Io.Dir.cwd()) catch |err| switch (err) { | |
| 51 | 51 | error.OutOfMemory => { |
| 52 | 52 | std.debug.print("ran out of memory initializing C compilation\n", .{}); |
| 53 | 53 | if (fast_exit) process.exit(1); |
| ... | ... | @@ -226,7 +226,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration |
| 226 | 226 | const dep_file_name = try d.getDepFileName(source, out_buf[0..std.fs.max_name_bytes]); |
| 227 | 227 | |
| 228 | 228 | const file = if (dep_file_name) |path| |
| 229 | d.comp.cwd.createFile(path, .{}) catch |er| | |
| 229 | d.comp.cwd.createFile(io, path, .{}) catch |er| | |
| 230 | 230 | return d.fatal("unable to create dependency file '{s}': {s}", .{ path, aro.Driver.errorDescription(er) }) |
| 231 | 231 | else |
| 232 | 232 | Io.File.stdout(); |
| ... | ... | @@ -253,10 +253,10 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration |
| 253 | 253 | if (d.output_name) |path| blk: { |
| 254 | 254 | if (std.mem.eql(u8, path, "-")) break :blk; |
| 255 | 255 | if (std.fs.path.dirname(path)) |dirname| { |
| 256 | std.fs.cwd().makePath(dirname) catch |err| | |
| 256 | Io.Dir.cwd().makePath(dirname) catch |err| | |
| 257 | 257 | return d.fatal("failed to create path to '{s}': {s}", .{ path, aro.Driver.errorDescription(err) }); |
| 258 | 258 | } |
| 259 | out_file = std.fs.cwd().createFile(path, .{}) catch |err| { | |
| 259 | out_file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| { | |
| 260 | 260 | return d.fatal("failed to create output file '{s}': {s}", .{ path, aro.Driver.errorDescription(err) }); |
| 261 | 261 | }; |
| 262 | 262 | close_out_file = true; |
lib/std/Build.zig+5-5| ... | ... | @@ -1702,13 +1702,13 @@ pub fn addCheckFile( |
| 1702 | 1702 | pub fn truncateFile(b: *Build, dest_path: []const u8) (Io.Dir.MakeError || Io.Dir.StatFileError)!void { |
| 1703 | 1703 | const io = b.graph.io; |
| 1704 | 1704 | if (b.verbose) log.info("truncate {s}", .{dest_path}); |
| 1705 | const cwd = fs.cwd(); | |
| 1706 | var src_file = cwd.createFile(dest_path, .{}) catch |err| switch (err) { | |
| 1705 | const cwd = Io.Dir.cwd(); | |
| 1706 | var src_file = cwd.createFile(io, dest_path, .{}) catch |err| switch (err) { | |
| 1707 | 1707 | error.FileNotFound => blk: { |
| 1708 | 1708 | if (fs.path.dirname(dest_path)) |dirname| { |
| 1709 | 1709 | try cwd.makePath(dirname); |
| 1710 | 1710 | } |
| 1711 | break :blk try cwd.createFile(dest_path, .{}); | |
| 1711 | break :blk try cwd.createFile(io, dest_path, .{}); | |
| 1712 | 1712 | }, |
| 1713 | 1713 | else => |e| return e, |
| 1714 | 1714 | }; |
| ... | ... | @@ -1846,7 +1846,7 @@ pub fn runAllowFail( |
| 1846 | 1846 | }; |
| 1847 | 1847 | errdefer b.allocator.free(stdout); |
| 1848 | 1848 | |
| 1849 | const term = try child.wait(); | |
| 1849 | const term = try child.wait(io); | |
| 1850 | 1850 | switch (term) { |
| 1851 | 1851 | .Exited => |code| { |
| 1852 | 1852 | if (code != 0) { |
| ... | ... | @@ -2193,7 +2193,7 @@ fn dependencyInner( |
| 2193 | 2193 | |
| 2194 | 2194 | const build_root: std.Build.Cache.Directory = .{ |
| 2195 | 2195 | .path = build_root_string, |
| 2196 | .handle = fs.cwd().openDir(build_root_string, .{}) catch |err| { | |
| 2196 | .handle = Io.Dir.cwd().openDir(build_root_string, .{}) catch |err| { | |
| 2197 | 2197 | std.debug.print("unable to open '{s}': {s}\n", .{ |
| 2198 | 2198 | build_root_string, @errorName(err), |
| 2199 | 2199 | }); |
lib/std/Build/Cache.zig+4-4| ... | ... | @@ -508,7 +508,7 @@ pub const Manifest = struct { |
| 508 | 508 | // and `want_shared_lock` is set, a shared lock might be sufficient, so we'll |
| 509 | 509 | // open with a shared lock instead. |
| 510 | 510 | while (true) { |
| 511 | if (self.cache.manifest_dir.createFile(&manifest_file_path, .{ | |
| 511 | if (self.cache.manifest_dir.createFile(io, &manifest_file_path, .{ | |
| 512 | 512 | .read = true, |
| 513 | 513 | .truncate = false, |
| 514 | 514 | .lock = .exclusive, |
| ... | ... | @@ -543,7 +543,7 @@ pub const Manifest = struct { |
| 543 | 543 | return error.CacheCheckFailed; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | if (self.cache.manifest_dir.createFile(&manifest_file_path, .{ | |
| 546 | if (self.cache.manifest_dir.createFile(io, &manifest_file_path, .{ | |
| 547 | 547 | .read = true, |
| 548 | 548 | .truncate = false, |
| 549 | 549 | .lock = .exclusive, |
| ... | ... | @@ -873,7 +873,7 @@ pub const Manifest = struct { |
| 873 | 873 | if (man.want_refresh_timestamp) { |
| 874 | 874 | man.want_refresh_timestamp = false; |
| 875 | 875 | |
| 876 | var file = man.cache.manifest_dir.createFile("timestamp", .{ | |
| 876 | var file = man.cache.manifest_dir.createFile(io, "timestamp", .{ | |
| 877 | 877 | .read = true, |
| 878 | 878 | .truncate = true, |
| 879 | 879 | }) catch |err| switch (err) { |
| ... | ... | @@ -1324,7 +1324,7 @@ fn hashFile(file: Io.File, bin_digest: *[Hasher.mac_length]u8) Io.File.PReadErro |
| 1324 | 1324 | fn testGetCurrentFileTimestamp(io: Io, dir: Io.Dir) !Io.Timestamp { |
| 1325 | 1325 | const test_out_file = "test-filetimestamp.tmp"; |
| 1326 | 1326 | |
| 1327 | var file = try dir.createFile(test_out_file, .{ | |
| 1327 | var file = try dir.createFile(io, test_out_file, .{ | |
| 1328 | 1328 | .read = true, |
| 1329 | 1329 | .truncate = true, |
| 1330 | 1330 | }); |
lib/std/Build/Step.zig+9-8| ... | ... | @@ -401,6 +401,9 @@ pub fn evalZigProcess( |
| 401 | 401 | web_server: ?*Build.WebServer, |
| 402 | 402 | gpa: Allocator, |
| 403 | 403 | ) !?Path { |
| 404 | const b = s.owner; | |
| 405 | const io = b.graph.io; | |
| 406 | ||
| 404 | 407 | // If an error occurs, it's happened in this command: |
| 405 | 408 | assert(s.result_failed_command == null); |
| 406 | 409 | s.result_failed_command = try allocPrintCmd(gpa, null, argv); |
| ... | ... | @@ -411,7 +414,7 @@ pub fn evalZigProcess( |
| 411 | 414 | const result = zigProcessUpdate(s, zp, watch, web_server, gpa) catch |err| switch (err) { |
| 412 | 415 | error.BrokenPipe => { |
| 413 | 416 | // Process restart required. |
| 414 | const term = zp.child.wait() catch |e| { | |
| 417 | const term = zp.child.wait(io) catch |e| { | |
| 415 | 418 | return s.fail("unable to wait for {s}: {t}", .{ argv[0], e }); |
| 416 | 419 | }; |
| 417 | 420 | _ = term; |
| ... | ... | @@ -427,7 +430,7 @@ pub fn evalZigProcess( |
| 427 | 430 | |
| 428 | 431 | if (s.result_error_msgs.items.len > 0 and result == null) { |
| 429 | 432 | // Crash detected. |
| 430 | const term = zp.child.wait() catch |e| { | |
| 433 | const term = zp.child.wait(io) catch |e| { | |
| 431 | 434 | return s.fail("unable to wait for {s}: {t}", .{ argv[0], e }); |
| 432 | 435 | }; |
| 433 | 436 | s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0; |
| ... | ... | @@ -439,9 +442,7 @@ pub fn evalZigProcess( |
| 439 | 442 | return result; |
| 440 | 443 | } |
| 441 | 444 | assert(argv.len != 0); |
| 442 | const b = s.owner; | |
| 443 | 445 | const arena = b.allocator; |
| 444 | const io = b.graph.io; | |
| 445 | 446 | |
| 446 | 447 | try handleChildProcUnsupported(s); |
| 447 | 448 | try handleVerbose(s.owner, null, argv); |
| ... | ... | @@ -478,7 +479,7 @@ pub fn evalZigProcess( |
| 478 | 479 | zp.child.stdin.?.close(io); |
| 479 | 480 | zp.child.stdin = null; |
| 480 | 481 | |
| 481 | const term = zp.child.wait() catch |err| { | |
| 482 | const term = zp.child.wait(io) catch |err| { | |
| 482 | 483 | return s.fail("unable to wait for {s}: {t}", .{ argv[0], err }); |
| 483 | 484 | }; |
| 484 | 485 | s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0; |
| ... | ... | @@ -519,7 +520,7 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u |
| 519 | 520 | pub fn installDir(s: *Step, dest_path: []const u8) !Io.Dir.MakePathStatus { |
| 520 | 521 | const b = s.owner; |
| 521 | 522 | try handleVerbose(b, null, &.{ "install", "-d", dest_path }); |
| 522 | return std.fs.cwd().makePathStatus(dest_path) catch |err| | |
| 523 | return Io.Dir.cwd().makePathStatus(dest_path) catch |err| | |
| 523 | 524 | return s.fail("unable to create dir '{s}': {t}", .{ dest_path, err }); |
| 524 | 525 | } |
| 525 | 526 | |
| ... | ... | @@ -895,7 +896,7 @@ pub fn addWatchInput(step: *Step, lazy_file: Build.LazyPath) Allocator.Error!voi |
| 895 | 896 | try addWatchInputFromPath(step, .{ |
| 896 | 897 | .root_dir = .{ |
| 897 | 898 | .path = null, |
| 898 | .handle = std.fs.cwd(), | |
| 899 | .handle = Io.Dir.cwd(), | |
| 899 | 900 | }, |
| 900 | 901 | .sub_path = std.fs.path.dirname(path_string) orelse "", |
| 901 | 902 | }, std.fs.path.basename(path_string)); |
| ... | ... | @@ -920,7 +921,7 @@ pub fn addDirectoryWatchInput(step: *Step, lazy_directory: Build.LazyPath) Alloc |
| 920 | 921 | try addDirectoryWatchInputFromPath(step, .{ |
| 921 | 922 | .root_dir = .{ |
| 922 | 923 | .path = null, |
| 923 | .handle = std.fs.cwd(), | |
| 924 | .handle = Io.Dir.cwd(), | |
| 924 | 925 | }, |
| 925 | 926 | .sub_path = path_string, |
| 926 | 927 | }); |
lib/std/Build/Step/CheckFile.zig+3-1| ... | ... | @@ -3,7 +3,9 @@ |
| 3 | 3 | //! TODO: generalize the code in std.testing.expectEqualStrings and make this |
| 4 | 4 | //! CheckFile step produce those helpful diagnostics when there is not a match. |
| 5 | 5 | const CheckFile = @This(); |
| 6 | ||
| 6 | 7 | const std = @import("std"); |
| 8 | const Io = std.Io; | |
| 7 | 9 | const Step = std.Build.Step; |
| 8 | 10 | const fs = std.fs; |
| 9 | 11 | const mem = std.mem; |
| ... | ... | @@ -53,7 +55,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 53 | 55 | try step.singleUnchangingWatchInput(check_file.source); |
| 54 | 56 | |
| 55 | 57 | const src_path = check_file.source.getPath2(b, step); |
| 56 | const contents = fs.cwd().readFileAlloc(src_path, b.allocator, .limited(check_file.max_bytes)) catch |err| { | |
| 58 | const contents = Io.Dir.cwd().readFileAlloc(src_path, b.allocator, .limited(check_file.max_bytes)) catch |err| { | |
| 57 | 59 | return step.fail("unable to read '{s}': {s}", .{ |
| 58 | 60 | src_path, @errorName(err), |
| 59 | 61 | }); |
lib/std/Build/Step/ConfigHeader.zig+5-3| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("std"); | |
| 2 | 1 | const ConfigHeader = @This(); |
| 2 | ||
| 3 | const std = @import("std"); | |
| 4 | const Io = std.Io; | |
| 3 | 5 | const Step = std.Build.Step; |
| 4 | 6 | const Allocator = std.mem.Allocator; |
| 5 | 7 | const Writer = std.Io.Writer; |
| ... | ... | @@ -205,7 +207,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 205 | 207 | .autoconf_undef, .autoconf_at => |file_source| { |
| 206 | 208 | try bw.writeAll(c_generated_line); |
| 207 | 209 | const src_path = file_source.getPath2(b, step); |
| 208 | const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| { | |
| 210 | const contents = Io.Dir.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| { | |
| 209 | 211 | return step.fail("unable to read autoconf input file '{s}': {s}", .{ |
| 210 | 212 | src_path, @errorName(err), |
| 211 | 213 | }); |
| ... | ... | @@ -219,7 +221,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 219 | 221 | .cmake => |file_source| { |
| 220 | 222 | try bw.writeAll(c_generated_line); |
| 221 | 223 | const src_path = file_source.getPath2(b, step); |
| 222 | const contents = std.fs.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| { | |
| 224 | const contents = Io.Dir.cwd().readFileAlloc(src_path, arena, .limited(config_header.max_bytes)) catch |err| { | |
| 223 | 225 | return step.fail("unable to read cmake input file '{s}': {s}", .{ |
| 224 | 226 | src_path, @errorName(err), |
| 225 | 227 | }); |
lib/std/Build/Step/Options.zig+8-7| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | const std = @import("std"); | |
| 1 | const Options = @This(); | |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | ||
| 4 | const std = @import("std"); | |
| 5 | const Io = std.Io; | |
| 3 | 6 | const fs = std.fs; |
| 4 | 7 | const Step = std.Build.Step; |
| 5 | 8 | const GeneratedFile = std.Build.GeneratedFile; |
| 6 | 9 | const LazyPath = std.Build.LazyPath; |
| 7 | 10 | |
| 8 | const Options = @This(); | |
| 9 | ||
| 10 | 11 | pub const base_id: Step.Id = .options; |
| 11 | 12 | |
| 12 | 13 | step: Step, |
| ... | ... | @@ -542,11 +543,11 @@ test Options { |
| 542 | 543 | .cache = .{ |
| 543 | 544 | .io = io, |
| 544 | 545 | .gpa = arena.allocator(), |
| 545 | .manifest_dir = std.fs.cwd(), | |
| 546 | .manifest_dir = Io.Dir.cwd(), | |
| 546 | 547 | }, |
| 547 | 548 | .zig_exe = "test", |
| 548 | 549 | .env_map = std.process.EnvMap.init(arena.allocator()), |
| 549 | .global_cache_root = .{ .path = "test", .handle = std.fs.cwd() }, | |
| 550 | .global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() }, | |
| 550 | 551 | .host = .{ |
| 551 | 552 | .query = .{}, |
| 552 | 553 | .result = try std.zig.system.resolveTargetQuery(io, .{}), |
| ... | ... | @@ -557,8 +558,8 @@ test Options { |
| 557 | 558 | |
| 558 | 559 | var builder = try std.Build.create( |
| 559 | 560 | &graph, |
| 560 | .{ .path = "test", .handle = std.fs.cwd() }, | |
| 561 | .{ .path = "test", .handle = std.fs.cwd() }, | |
| 561 | .{ .path = "test", .handle = Io.Dir.cwd() }, | |
| 562 | .{ .path = "test", .handle = Io.Dir.cwd() }, | |
| 562 | 563 | &.{}, |
| 563 | 564 | ); |
| 564 | 565 |
lib/std/Build/Step/Run.zig+1-1| ... | ... | @@ -1023,7 +1023,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 1023 | 1023 | |
| 1024 | 1024 | try runCommand(run, argv_list.items, has_side_effects, tmp_dir_path, options, null); |
| 1025 | 1025 | |
| 1026 | const dep_file_dir = std.fs.cwd(); | |
| 1026 | const dep_file_dir = Io.Dir.cwd(); | |
| 1027 | 1027 | const dep_file_basename = dep_output_file.generated_file.getPath2(b, step); |
| 1028 | 1028 | if (has_side_effects) |
| 1029 | 1029 | try man.addDepFile(dep_file_dir, dep_file_basename) |
lib/std/Build/Watch.zig+8-8| ... | ... | @@ -122,7 +122,7 @@ const Os = switch (builtin.os.tag) { |
| 122 | 122 | }) catch return error.NameTooLong; |
| 123 | 123 | const stack_ptr: *std.os.linux.file_handle = @ptrCast(&file_handle_buffer); |
| 124 | 124 | stack_ptr.handle_bytes = file_handle_buffer.len - @sizeOf(std.os.linux.file_handle); |
| 125 | try posix.name_to_handle_at(path.root_dir.handle.fd, adjusted_path, stack_ptr, mount_id, std.os.linux.AT.HANDLE_FID); | |
| 125 | try posix.name_to_handle_at(path.root_dir.handle.handle, adjusted_path, stack_ptr, mount_id, std.os.linux.AT.HANDLE_FID); | |
| 126 | 126 | const stack_lfh: FileHandle = .{ .handle = stack_ptr }; |
| 127 | 127 | return stack_lfh.clone(gpa); |
| 128 | 128 | } |
| ... | ... | @@ -222,7 +222,7 @@ const Os = switch (builtin.os.tag) { |
| 222 | 222 | posix.fanotify_mark(fan_fd, .{ |
| 223 | 223 | .ADD = true, |
| 224 | 224 | .ONLYDIR = true, |
| 225 | }, fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| { | |
| 225 | }, fan_mask, path.root_dir.handle.handle, path.subPathOrDot()) catch |err| { | |
| 226 | 226 | fatal("unable to watch {f}: {s}", .{ path, @errorName(err) }); |
| 227 | 227 | }; |
| 228 | 228 | } |
| ... | ... | @@ -275,7 +275,7 @@ const Os = switch (builtin.os.tag) { |
| 275 | 275 | posix.fanotify_mark(fan_fd, .{ |
| 276 | 276 | .REMOVE = true, |
| 277 | 277 | .ONLYDIR = true, |
| 278 | }, fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| switch (err) { | |
| 278 | }, fan_mask, path.root_dir.handle.handle, path.subPathOrDot()) catch |err| switch (err) { | |
| 279 | 279 | error.FileNotFound => {}, // Expected, harmless. |
| 280 | 280 | else => |e| std.log.warn("unable to unwatch '{f}': {s}", .{ path, @errorName(e) }), |
| 281 | 281 | }; |
| ... | ... | @@ -353,7 +353,7 @@ const Os = switch (builtin.os.tag) { |
| 353 | 353 | // The following code is a drawn out NtCreateFile call. (mostly adapted from Io.Dir.makeOpenDirAccessMaskW) |
| 354 | 354 | // It's necessary in order to get the specific flags that are required when calling ReadDirectoryChangesW. |
| 355 | 355 | var dir_handle: windows.HANDLE = undefined; |
| 356 | const root_fd = path.root_dir.handle.fd; | |
| 356 | const root_fd = path.root_dir.handle.handle; | |
| 357 | 357 | const sub_path = path.subPathOrDot(); |
| 358 | 358 | const sub_path_w = try windows.sliceToPrefixedFileW(root_fd, sub_path); |
| 359 | 359 | const path_len_bytes = std.math.cast(u16, sub_path_w.len * 2) orelse return error.NameTooLong; |
| ... | ... | @@ -681,9 +681,9 @@ const Os = switch (builtin.os.tag) { |
| 681 | 681 | if (!gop.found_existing) { |
| 682 | 682 | const skip_open_dir = path.sub_path.len == 0; |
| 683 | 683 | const dir_fd = if (skip_open_dir) |
| 684 | path.root_dir.handle.fd | |
| 684 | path.root_dir.handle.handle | |
| 685 | 685 | else |
| 686 | posix.openat(path.root_dir.handle.fd, path.sub_path, dir_open_flags, 0) catch |err| { | |
| 686 | posix.openat(path.root_dir.handle.handle, path.sub_path, dir_open_flags, 0) catch |err| { | |
| 687 | 687 | fatal("failed to open directory {f}: {s}", .{ path, @errorName(err) }); |
| 688 | 688 | }; |
| 689 | 689 | // Empirically the dir has to stay open or else no events are triggered. |
| ... | ... | @@ -750,7 +750,7 @@ const Os = switch (builtin.os.tag) { |
| 750 | 750 | // to access that data via the dir_fd field. |
| 751 | 751 | const path = w.dir_table.keys()[i]; |
| 752 | 752 | const dir_fd = if (path.sub_path.len == 0) |
| 753 | path.root_dir.handle.fd | |
| 753 | path.root_dir.handle.handle | |
| 754 | 754 | else |
| 755 | 755 | handles.items(.dir_fd)[i]; |
| 756 | 756 | assert(dir_fd != -1); |
| ... | ... | @@ -761,7 +761,7 @@ const Os = switch (builtin.os.tag) { |
| 761 | 761 | const last_dir_fd = fd: { |
| 762 | 762 | const last_path = w.dir_table.keys()[handles.len - 1]; |
| 763 | 763 | const last_dir_fd = if (last_path.sub_path.len == 0) |
| 764 | last_path.root_dir.handle.fd | |
| 764 | last_path.root_dir.handle.handle | |
| 765 | 765 | else |
| 766 | 766 | handles.items(.dir_fd)[handles.len - 1]; |
| 767 | 767 | assert(last_dir_fd != -1); |
lib/std/Io/File.zig+8| ... | ... | @@ -527,6 +527,14 @@ pub fn writerStreaming(file: File, io: Io, buffer: []u8) Writer { |
| 527 | 527 | return .initStreaming(file, io, buffer); |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | /// Equivalent to creating a streaming writer, writing `bytes`, and then flushing. | |
| 531 | pub fn writeStreamingAll(file: File, io: Io, bytes: []const u8) Writer.Error!void { | |
| 532 | var index: usize = 0; | |
| 533 | while (index < bytes.len) { | |
| 534 | index += try io.vtable.fileWriteStreaming(io.userdata, file, &.{}, &.{bytes[index..]}, 1); | |
| 535 | } | |
| 536 | } | |
| 537 | ||
| 530 | 538 | pub const LockError = error{ |
| 531 | 539 | SystemResources, |
| 532 | 540 | FileLocksUnsupported, |
lib/std/Io/Threaded.zig+3-6| ... | ... | @@ -2361,7 +2361,7 @@ fn dirCreateFilePosix( |
| 2361 | 2361 | .NFILE => return error.SystemFdQuotaExceeded, |
| 2362 | 2362 | .NODEV => return error.NoDevice, |
| 2363 | 2363 | .NOENT => return error.FileNotFound, |
| 2364 | .SRCH => return error.ProcessNotFound, | |
| 2364 | .SRCH => return error.FileNotFound, // Linux when accessing procfs. | |
| 2365 | 2365 | .NOMEM => return error.SystemResources, |
| 2366 | 2366 | .NOSPC => return error.NoSpaceLeft, |
| 2367 | 2367 | .NOTDIR => return error.NotDir, |
| ... | ... | @@ -2670,7 +2670,7 @@ fn dirOpenFilePosix( |
| 2670 | 2670 | .NFILE => return error.SystemFdQuotaExceeded, |
| 2671 | 2671 | .NODEV => return error.NoDevice, |
| 2672 | 2672 | .NOENT => return error.FileNotFound, |
| 2673 | .SRCH => return error.ProcessNotFound, | |
| 2673 | .SRCH => return error.FileNotFound, // Linux when opening procfs files. | |
| 2674 | 2674 | .NOMEM => return error.SystemResources, |
| 2675 | 2675 | .NOSPC => return error.NoSpaceLeft, |
| 2676 | 2676 | .NOTDIR => return error.NotDir, |
| ... | ... | @@ -3287,7 +3287,7 @@ fn dirRealPathPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, out_b |
| 3287 | 3287 | .NFILE => return error.SystemFdQuotaExceeded, |
| 3288 | 3288 | .NODEV => return error.NoDevice, |
| 3289 | 3289 | .NOENT => return error.FileNotFound, |
| 3290 | .SRCH => return error.ProcessNotFound, | |
| 3290 | .SRCH => return error.FileNotFound, // Linux when accessing procfs. | |
| 3291 | 3291 | .NOMEM => return error.SystemResources, |
| 3292 | 3292 | .NOSPC => return error.NoSpaceLeft, |
| 3293 | 3293 | .NOTDIR => return error.NotDir, |
| ... | ... | @@ -5548,7 +5548,6 @@ fn fileReadStreamingPosix(userdata: ?*anyopaque, file: File, data: [][]u8) File. |
| 5548 | 5548 | switch (e) { |
| 5549 | 5549 | .INVAL => |err| return errnoBug(err), |
| 5550 | 5550 | .FAULT => |err| return errnoBug(err), |
| 5551 | .SRCH => return error.ProcessNotFound, | |
| 5552 | 5551 | .AGAIN => return error.WouldBlock, |
| 5553 | 5552 | .BADF => |err| { |
| 5554 | 5553 | if (native_os == .wasi) return error.NotOpenForReading; // File operation on directory. |
| ... | ... | @@ -5672,7 +5671,6 @@ fn fileReadPositionalPosix(userdata: ?*anyopaque, file: File, data: [][]u8, offs |
| 5672 | 5671 | switch (e) { |
| 5673 | 5672 | .INVAL => |err| return errnoBug(err), |
| 5674 | 5673 | .FAULT => |err| return errnoBug(err), |
| 5675 | .SRCH => return error.ProcessNotFound, | |
| 5676 | 5674 | .AGAIN => return error.WouldBlock, |
| 5677 | 5675 | .BADF => |err| { |
| 5678 | 5676 | if (native_os == .wasi) return error.NotOpenForReading; // File operation on directory. |
| ... | ... | @@ -6312,7 +6310,6 @@ fn fileWriteStreaming( |
| 6312 | 6310 | switch (e) { |
| 6313 | 6311 | .INVAL => return error.InvalidArgument, |
| 6314 | 6312 | .FAULT => |err| return errnoBug(err), |
| 6315 | .SRCH => return error.ProcessNotFound, | |
| 6316 | 6313 | .AGAIN => return error.WouldBlock, |
| 6317 | 6314 | .BADF => return error.NotOpenForWriting, // Can be a race condition. |
| 6318 | 6315 | .DESTADDRREQ => |err| return errnoBug(err), // `connect` was never called. |
lib/std/Io/Writer.zig+3-3| ... | ... | @@ -2835,7 +2835,7 @@ test "discarding sendFile" { |
| 2835 | 2835 | var tmp_dir = testing.tmpDir(.{}); |
| 2836 | 2836 | defer tmp_dir.cleanup(); |
| 2837 | 2837 | |
| 2838 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); | |
| 2838 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); | |
| 2839 | 2839 | defer file.close(io); |
| 2840 | 2840 | var r_buffer: [256]u8 = undefined; |
| 2841 | 2841 | var file_writer: File.Writer = .init(file, &r_buffer); |
| ... | ... | @@ -2857,7 +2857,7 @@ test "allocating sendFile" { |
| 2857 | 2857 | var tmp_dir = testing.tmpDir(.{}); |
| 2858 | 2858 | defer tmp_dir.cleanup(); |
| 2859 | 2859 | |
| 2860 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); | |
| 2860 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); | |
| 2861 | 2861 | defer file.close(io); |
| 2862 | 2862 | var r_buffer: [2]u8 = undefined; |
| 2863 | 2863 | var file_writer: File.Writer = .init(file, &r_buffer); |
| ... | ... | @@ -2881,7 +2881,7 @@ test sendFileReading { |
| 2881 | 2881 | var tmp_dir = testing.tmpDir(.{}); |
| 2882 | 2882 | defer tmp_dir.cleanup(); |
| 2883 | 2883 | |
| 2884 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); | |
| 2884 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); | |
| 2885 | 2885 | defer file.close(io); |
| 2886 | 2886 | var r_buffer: [2]u8 = undefined; |
| 2887 | 2887 | var file_writer: File.Writer = .init(file, &r_buffer); |
lib/std/Io/net/test.zig+1-1| ... | ... | @@ -278,7 +278,7 @@ test "listen on a unix socket, send bytes, receive bytes" { |
| 278 | 278 | defer testing.allocator.free(socket_path); |
| 279 | 279 | |
| 280 | 280 | const socket_addr = try net.UnixAddress.init(socket_path); |
| 281 | defer std.fs.cwd().deleteFile(socket_path) catch {}; | |
| 281 | defer Io.Dir.cwd().deleteFile(socket_path) catch {}; | |
| 282 | 282 | |
| 283 | 283 | var server = try socket_addr.listen(io, .{}); |
| 284 | 284 | defer server.socket.close(io); |
lib/std/Io/test.zig+5-5| ... | ... | @@ -27,7 +27,7 @@ test "write a file, read it, then delete it" { |
| 27 | 27 | random.bytes(data[0..]); |
| 28 | 28 | const tmp_file_name = "temp_test_file.txt"; |
| 29 | 29 | { |
| 30 | var file = try tmp.dir.createFile(tmp_file_name, .{}); | |
| 30 | var file = try tmp.dir.createFile(io, tmp_file_name, .{}); | |
| 31 | 31 | defer file.close(io); |
| 32 | 32 | |
| 33 | 33 | var file_writer = file.writer(&.{}); |
| ... | ... | @@ -40,7 +40,7 @@ test "write a file, read it, then delete it" { |
| 40 | 40 | |
| 41 | 41 | { |
| 42 | 42 | // Make sure the exclusive flag is honored. |
| 43 | try expectError(File.OpenError.PathAlreadyExists, tmp.dir.createFile(tmp_file_name, .{ .exclusive = true })); | |
| 43 | try expectError(File.OpenError.PathAlreadyExists, tmp.dir.createFile(io, tmp_file_name, .{ .exclusive = true })); | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | { |
| ... | ... | @@ -70,7 +70,7 @@ test "File seek ops" { |
| 70 | 70 | const io = testing.io; |
| 71 | 71 | |
| 72 | 72 | const tmp_file_name = "temp_test_file.txt"; |
| 73 | var file = try tmp.dir.createFile(tmp_file_name, .{}); | |
| 73 | var file = try tmp.dir.createFile(io, tmp_file_name, .{}); | |
| 74 | 74 | defer file.close(io); |
| 75 | 75 | |
| 76 | 76 | try file.writeAll(&([_]u8{0x55} ** 8192)); |
| ... | ... | @@ -96,7 +96,7 @@ test "setEndPos" { |
| 96 | 96 | defer tmp.cleanup(); |
| 97 | 97 | |
| 98 | 98 | const tmp_file_name = "temp_test_file.txt"; |
| 99 | var file = try tmp.dir.createFile(tmp_file_name, .{}); | |
| 99 | var file = try tmp.dir.createFile(io, tmp_file_name, .{}); | |
| 100 | 100 | defer file.close(io); |
| 101 | 101 | |
| 102 | 102 | // Verify that the file size changes and the file offset is not moved |
| ... | ... | @@ -121,7 +121,7 @@ test "updateTimes" { |
| 121 | 121 | defer tmp.cleanup(); |
| 122 | 122 | |
| 123 | 123 | const tmp_file_name = "just_a_temporary_file.txt"; |
| 124 | var file = try tmp.dir.createFile(tmp_file_name, .{ .read = true }); | |
| 124 | var file = try tmp.dir.createFile(io, tmp_file_name, .{ .read = true }); | |
| 125 | 125 | defer file.close(io); |
| 126 | 126 | |
| 127 | 127 | const stat_old = try file.stat(); |
lib/std/Thread.zig+2-2| ... | ... | @@ -208,7 +208,7 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void { |
| 208 | 208 | var buf: [32]u8 = undefined; |
| 209 | 209 | const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()}); |
| 210 | 210 | |
| 211 | const file = try std.fs.cwd().openFile(io, path, .{ .mode = .write_only }); | |
| 211 | const file = try Io.Dir.cwd().openFile(io, path, .{ .mode = .write_only }); | |
| 212 | 212 | defer file.close(io); |
| 213 | 213 | |
| 214 | 214 | try file.writeAll(name); |
| ... | ... | @@ -325,7 +325,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 325 | 325 | var threaded: std.Io.Threaded = .init_single_threaded; |
| 326 | 326 | const io = threaded.ioBasic(); |
| 327 | 327 | |
| 328 | const file = try std.fs.cwd().openFile(io, path, .{}); | |
| 328 | const file = try Io.Dir.cwd().openFile(io, path, .{}); | |
| 329 | 329 | defer file.close(io); |
| 330 | 330 | |
| 331 | 331 | var file_reader = file.readerStreaming(io, &.{}); |
lib/std/crypto/Certificate/Bundle/macos.zig+1-1| ... | ... | @@ -19,7 +19,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp) RescanM |
| 19 | 19 | |
| 20 | 20 | _ = io; // TODO migrate file system to use std.Io |
| 21 | 21 | for (keychain_paths) |keychain_path| { |
| 22 | const bytes = std.fs.cwd().readFileAlloc(keychain_path, gpa, .limited(std.math.maxInt(u32))) catch |err| switch (err) { | |
| 22 | const bytes = Io.Dir.cwd().readFileAlloc(keychain_path, gpa, .limited(std.math.maxInt(u32))) catch |err| switch (err) { | |
| 23 | 23 | error.StreamTooLong => return error.FileTooBig, |
| 24 | 24 | else => |e| return e, |
| 25 | 25 | }; |
lib/std/crypto/codecs/asn1/test.zig+2-2| ... | ... | @@ -73,8 +73,8 @@ test AllTypes { |
| 73 | 73 | try std.testing.expectEqualSlices(u8, encoded, buf); |
| 74 | 74 | |
| 75 | 75 | // Use this to update test file. |
| 76 | // const dir = try std.fs.cwd().openDir("lib/std/crypto/asn1", .{}); | |
| 77 | // var file = try dir.createFile(path, .{}); | |
| 76 | // const dir = try Io.Dir.cwd().openDir("lib/std/crypto/asn1", .{}); | |
| 77 | // var file = try dir.createFile(io, path, .{}); | |
| 78 | 78 | // defer file.close(io); |
| 79 | 79 | // try file.writeAll(buf); |
| 80 | 80 | } |
lib/std/debug.zig+10-10| ... | ... | @@ -60,7 +60,7 @@ pub const cpu_context = @import("debug/cpu_context.zig"); |
| 60 | 60 | /// }; |
| 61 | 61 | /// /// Only required if `can_unwind == true`. Unwinds a single stack frame, returning the frame's |
| 62 | 62 | /// /// return address, or 0 if the end of the stack has been reached. |
| 63 | /// pub fn unwindFrame(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) SelfInfoError!usize; | |
| 63 | /// pub fn unwindFrame(si: *SelfInfo, gpa: Allocator, io: Io, context: *UnwindContext) SelfInfoError!usize; | |
| 64 | 64 | /// ``` |
| 65 | 65 | pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfInfo")) |
| 66 | 66 | root.debug.SelfInfo |
| ... | ... | @@ -558,9 +558,9 @@ pub fn defaultPanic( |
| 558 | 558 | stderr.print("{s}\n", .{msg}) catch break :trace; |
| 559 | 559 | |
| 560 | 560 | if (@errorReturnTrace()) |t| if (t.index > 0) { |
| 561 | stderr.writeAll("error return context:\n") catch break :trace; | |
| 561 | stderr.writeStreamingAll("error return context:\n") catch break :trace; | |
| 562 | 562 | writeStackTrace(t, stderr, tty_config) catch break :trace; |
| 563 | stderr.writeAll("\nstack trace:\n") catch break :trace; | |
| 563 | stderr.writeStreamingAll("\nstack trace:\n") catch break :trace; | |
| 564 | 564 | }; |
| 565 | 565 | writeCurrentStackTrace(.{ |
| 566 | 566 | .first_address = first_trace_addr orelse @returnAddress(), |
| ... | ... | @@ -575,7 +575,7 @@ pub fn defaultPanic( |
| 575 | 575 | // A panic happened while trying to print a previous panic message. |
| 576 | 576 | // We're still holding the mutex but that's fine as we're going to |
| 577 | 577 | // call abort(). |
| 578 | File.stderr().writeAll("aborting due to recursive panic\n") catch {}; | |
| 578 | File.stderr().writeStreamingAll("aborting due to recursive panic\n") catch {}; | |
| 579 | 579 | }, |
| 580 | 580 | else => {}, // Panicked while printing the recursive panic message. |
| 581 | 581 | } |
| ... | ... | @@ -960,7 +960,7 @@ const StackIterator = union(enum) { |
| 960 | 960 | }, |
| 961 | 961 | }; |
| 962 | 962 | |
| 963 | fn next(it: *StackIterator) Result { | |
| 963 | fn next(it: *StackIterator, io: Io) Result { | |
| 964 | 964 | switch (it.*) { |
| 965 | 965 | .ctx_first => |context_ptr| { |
| 966 | 966 | // After the first frame, start actually unwinding. |
| ... | ... | @@ -976,7 +976,7 @@ const StackIterator = union(enum) { |
| 976 | 976 | .di => |*unwind_context| { |
| 977 | 977 | const di = getSelfDebugInfo() catch unreachable; |
| 978 | 978 | const di_gpa = getDebugInfoAllocator(); |
| 979 | const ret_addr = di.unwindFrame(di_gpa, unwind_context) catch |err| { | |
| 979 | const ret_addr = di.unwindFrame(di_gpa, io, unwind_context) catch |err| { | |
| 980 | 980 | const pc = unwind_context.pc; |
| 981 | 981 | const fp = unwind_context.getFp(); |
| 982 | 982 | it.* = .{ .fp = fp }; |
| ... | ... | @@ -1297,7 +1297,7 @@ test printLineFromFile { |
| 1297 | 1297 | aw.clearRetainingCapacity(); |
| 1298 | 1298 | } |
| 1299 | 1299 | { |
| 1300 | const file = try test_dir.dir.createFile("line_overlaps_page_boundary.zig", .{}); | |
| 1300 | const file = try test_dir.dir.createFile(io, "line_overlaps_page_boundary.zig", .{}); | |
| 1301 | 1301 | defer file.close(io); |
| 1302 | 1302 | const path = try fs.path.join(gpa, &.{ test_dir_path, "line_overlaps_page_boundary.zig" }); |
| 1303 | 1303 | defer gpa.free(path); |
| ... | ... | @@ -1316,7 +1316,7 @@ test printLineFromFile { |
| 1316 | 1316 | aw.clearRetainingCapacity(); |
| 1317 | 1317 | } |
| 1318 | 1318 | { |
| 1319 | const file = try test_dir.dir.createFile("file_ends_on_page_boundary.zig", .{}); | |
| 1319 | const file = try test_dir.dir.createFile(io, "file_ends_on_page_boundary.zig", .{}); | |
| 1320 | 1320 | defer file.close(io); |
| 1321 | 1321 | const path = try fs.path.join(gpa, &.{ test_dir_path, "file_ends_on_page_boundary.zig" }); |
| 1322 | 1322 | defer gpa.free(path); |
| ... | ... | @@ -1330,7 +1330,7 @@ test printLineFromFile { |
| 1330 | 1330 | aw.clearRetainingCapacity(); |
| 1331 | 1331 | } |
| 1332 | 1332 | { |
| 1333 | const file = try test_dir.dir.createFile("very_long_first_line_spanning_multiple_pages.zig", .{}); | |
| 1333 | const file = try test_dir.dir.createFile(io, "very_long_first_line_spanning_multiple_pages.zig", .{}); | |
| 1334 | 1334 | defer file.close(io); |
| 1335 | 1335 | const path = try fs.path.join(gpa, &.{ test_dir_path, "very_long_first_line_spanning_multiple_pages.zig" }); |
| 1336 | 1336 | defer gpa.free(path); |
| ... | ... | @@ -1356,7 +1356,7 @@ test printLineFromFile { |
| 1356 | 1356 | aw.clearRetainingCapacity(); |
| 1357 | 1357 | } |
| 1358 | 1358 | { |
| 1359 | const file = try test_dir.dir.createFile("file_of_newlines.zig", .{}); | |
| 1359 | const file = try test_dir.dir.createFile(io, "file_of_newlines.zig", .{}); | |
| 1360 | 1360 | defer file.close(io); |
| 1361 | 1361 | const path = try fs.path.join(gpa, &.{ test_dir_path, "file_of_newlines.zig" }); |
| 1362 | 1362 | defer gpa.free(path); |
lib/std/debug/ElfFile.zig+1-1| ... | ... | @@ -375,7 +375,7 @@ fn loadSeparateDebugFile( |
| 375 | 375 | args: anytype, |
| 376 | 376 | ) Allocator.Error!?[]align(std.heap.page_size_min) const u8 { |
| 377 | 377 | const path = try std.fmt.allocPrint(arena, fmt, args); |
| 378 | const elf_file = std.fs.cwd().openFile(io, path, .{}) catch return null; | |
| 378 | const elf_file = Io.Dir.cwd().openFile(io, path, .{}) catch return null; | |
| 379 | 379 | defer elf_file.close(io); |
| 380 | 380 | |
| 381 | 381 | const result = loadInner(arena, elf_file, opt_crc) catch |err| switch (err) { |
lib/std/debug/MachOFile.zig+1-1| ... | ... | @@ -512,7 +512,7 @@ fn loadOFile(gpa: Allocator, io: Io, o_file_name: []const u8) !OFile { |
| 512 | 512 | |
| 513 | 513 | /// Uses `mmap` to map the file at `path` into memory. |
| 514 | 514 | fn mapDebugInfoFile(io: Io, path: []const u8) ![]align(std.heap.page_size_min) const u8 { |
| 515 | const file = std.fs.cwd().openFile(io, path, .{}) catch |err| switch (err) { | |
| 515 | const file = Io.Dir.cwd().openFile(io, path, .{}) catch |err| switch (err) { | |
| 516 | 516 | error.FileNotFound => return error.MissingDebugInfo, |
| 517 | 517 | else => return error.ReadFailed, |
| 518 | 518 | }; |
lib/std/debug/SelfInfo/Elf.zig+9-10| ... | ... | @@ -29,13 +29,12 @@ pub fn deinit(si: *SelfInfo, gpa: Allocator) void { |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | pub fn getSymbol(si: *SelfInfo, gpa: Allocator, io: Io, address: usize) Error!std.debug.Symbol { |
| 32 | _ = io; | |
| 33 | 32 | const module = try si.findModule(gpa, address, .exclusive); |
| 34 | 33 | defer si.rwlock.unlock(); |
| 35 | 34 | |
| 36 | 35 | const vaddr = address - module.load_offset; |
| 37 | 36 | |
| 38 | const loaded_elf = try module.getLoadedElf(gpa); | |
| 37 | const loaded_elf = try module.getLoadedElf(gpa, io); | |
| 39 | 38 | if (loaded_elf.file.dwarf) |*dwarf| { |
| 40 | 39 | if (!loaded_elf.scanned_dwarf) { |
| 41 | 40 | dwarf.open(gpa, native_endian) catch |err| switch (err) { |
| ... | ... | @@ -180,7 +179,7 @@ comptime { |
| 180 | 179 | } |
| 181 | 180 | } |
| 182 | 181 | pub const UnwindContext = Dwarf.SelfUnwinder; |
| 183 | pub fn unwindFrame(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) Error!usize { | |
| 182 | pub fn unwindFrame(si: *SelfInfo, gpa: Allocator, io: Io, context: *UnwindContext) Error!usize { | |
| 184 | 183 | comptime assert(can_unwind); |
| 185 | 184 | |
| 186 | 185 | { |
| ... | ... | @@ -201,7 +200,7 @@ pub fn unwindFrame(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) Error |
| 201 | 200 | @memset(si.unwind_cache.?, .empty); |
| 202 | 201 | } |
| 203 | 202 | |
| 204 | const unwind_sections = try module.getUnwindSections(gpa); | |
| 203 | const unwind_sections = try module.getUnwindSections(gpa, io); | |
| 205 | 204 | for (unwind_sections) |*unwind| { |
| 206 | 205 | if (context.computeRules(gpa, unwind, module.load_offset, null)) |entry| { |
| 207 | 206 | entry.populate(si.unwind_cache.?); |
| ... | ... | @@ -261,12 +260,12 @@ const Module = struct { |
| 261 | 260 | }; |
| 262 | 261 | |
| 263 | 262 | /// Assumes we already hold an exclusive lock. |
| 264 | fn getUnwindSections(mod: *Module, gpa: Allocator) Error![]Dwarf.Unwind { | |
| 265 | if (mod.unwind == null) mod.unwind = loadUnwindSections(mod, gpa); | |
| 263 | fn getUnwindSections(mod: *Module, gpa: Allocator, io: Io) Error![]Dwarf.Unwind { | |
| 264 | if (mod.unwind == null) mod.unwind = loadUnwindSections(mod, gpa, io); | |
| 266 | 265 | const us = &(mod.unwind.? catch |err| return err); |
| 267 | 266 | return us.buf[0..us.len]; |
| 268 | 267 | } |
| 269 | fn loadUnwindSections(mod: *Module, gpa: Allocator) Error!UnwindSections { | |
| 268 | fn loadUnwindSections(mod: *Module, gpa: Allocator, io: Io) Error!UnwindSections { | |
| 270 | 269 | var us: UnwindSections = .{ |
| 271 | 270 | .buf = undefined, |
| 272 | 271 | .len = 0, |
| ... | ... | @@ -284,7 +283,7 @@ const Module = struct { |
| 284 | 283 | } else { |
| 285 | 284 | // There is no `.eh_frame_hdr` section. There may still be an `.eh_frame` or `.debug_frame` |
| 286 | 285 | // section, but we'll have to load the binary to get at it. |
| 287 | const loaded = try mod.getLoadedElf(gpa); | |
| 286 | const loaded = try mod.getLoadedElf(gpa, io); | |
| 288 | 287 | // If both are present, we can't just pick one -- the info could be split between them. |
| 289 | 288 | // `.debug_frame` is likely to be the more complete section, so we'll prioritize that one. |
| 290 | 289 | if (loaded.file.debug_frame) |*debug_frame| { |
| ... | ... | @@ -325,7 +324,7 @@ const Module = struct { |
| 325 | 324 | } |
| 326 | 325 | fn loadElf(mod: *Module, gpa: Allocator, io: Io) Error!LoadedElf { |
| 327 | 326 | const load_result = if (mod.name.len > 0) res: { |
| 328 | var file = std.fs.cwd().openFile(io, mod.name, .{}) catch return error.MissingDebugInfo; | |
| 327 | var file = Io.Dir.cwd().openFile(io, mod.name, .{}) catch return error.MissingDebugInfo; | |
| 329 | 328 | defer file.close(io); |
| 330 | 329 | break :res std.debug.ElfFile.load(gpa, file, mod.build_id, &.native(mod.name)); |
| 331 | 330 | } else res: { |
| ... | ... | @@ -334,7 +333,7 @@ const Module = struct { |
| 334 | 333 | else => return error.ReadFailed, |
| 335 | 334 | }; |
| 336 | 335 | defer gpa.free(path); |
| 337 | var file = std.fs.cwd().openFile(io, path, .{}) catch return error.MissingDebugInfo; | |
| 336 | var file = Io.Dir.cwd().openFile(io, path, .{}) catch return error.MissingDebugInfo; | |
| 338 | 337 | defer file.close(io); |
| 339 | 338 | break :res std.debug.ElfFile.load(gpa, file, mod.build_id, &.native(path)); |
| 340 | 339 | }; |
lib/std/debug/SelfInfo/MachO.zig+1-1| ... | ... | @@ -616,7 +616,7 @@ test { |
| 616 | 616 | |
| 617 | 617 | /// Uses `mmap` to map the file at `path` into memory. |
| 618 | 618 | fn mapDebugInfoFile(io: Io, path: []const u8) ![]align(std.heap.page_size_min) const u8 { |
| 619 | const file = std.fs.cwd().openFile(io, path, .{}) catch |err| switch (err) { | |
| 619 | const file = Io.Dir.cwd().openFile(io, path, .{}) catch |err| switch (err) { | |
| 620 | 620 | error.FileNotFound => return error.MissingDebugInfo, |
| 621 | 621 | else => return error.ReadFailed, |
| 622 | 622 | }; |
lib/std/debug/SelfInfo/Windows.zig+2-2| ... | ... | @@ -432,7 +432,7 @@ const Module = struct { |
| 432 | 432 | break :pdb null; |
| 433 | 433 | }; |
| 434 | 434 | const pdb_file_open_result = if (fs.path.isAbsolute(path)) res: { |
| 435 | break :res std.fs.cwd().openFile(io, path, .{}); | |
| 435 | break :res Io.Dir.cwd().openFile(io, path, .{}); | |
| 436 | 436 | } else res: { |
| 437 | 437 | const self_dir = std.process.executableDirPathAlloc(io, gpa) catch |err| switch (err) { |
| 438 | 438 | error.OutOfMemory, error.Unexpected => |e| return e, |
| ... | ... | @@ -441,7 +441,7 @@ const Module = struct { |
| 441 | 441 | defer gpa.free(self_dir); |
| 442 | 442 | const abs_path = try fs.path.join(gpa, &.{ self_dir, path }); |
| 443 | 443 | defer gpa.free(abs_path); |
| 444 | break :res std.fs.cwd().openFile(io, abs_path, .{}); | |
| 444 | break :res Io.Dir.cwd().openFile(io, abs_path, .{}); | |
| 445 | 445 | }; |
| 446 | 446 | const pdb_file = pdb_file_open_result catch |err| switch (err) { |
| 447 | 447 | error.FileNotFound, error.IsDir => break :pdb null, |
lib/std/dynamic_library.zig+4-4| ... | ... | @@ -160,7 +160,7 @@ pub const ElfDynLib = struct { |
| 160 | 160 | fn openPath(path: []const u8, io: Io) !Io.Dir { |
| 161 | 161 | if (path.len == 0) return error.NotDir; |
| 162 | 162 | var parts = std.mem.tokenizeScalar(u8, path, '/'); |
| 163 | var parent = if (path[0] == '/') try std.fs.cwd().openDir("/", .{}) else std.fs.cwd(); | |
| 163 | var parent = if (path[0] == '/') try Io.Dir.cwd().openDir("/", .{}) else Io.Dir.cwd(); | |
| 164 | 164 | while (parts.next()) |part| { |
| 165 | 165 | const child = try parent.openDir(part, .{}); |
| 166 | 166 | parent.close(io); |
| ... | ... | @@ -174,7 +174,7 @@ pub const ElfDynLib = struct { |
| 174 | 174 | while (paths.next()) |p| { |
| 175 | 175 | var dir = openPath(p) catch continue; |
| 176 | 176 | defer dir.close(io); |
| 177 | const fd = posix.openat(dir.fd, file_name, .{ | |
| 177 | const fd = posix.openat(dir.handle, file_name, .{ | |
| 178 | 178 | .ACCMODE = .RDONLY, |
| 179 | 179 | .CLOEXEC = true, |
| 180 | 180 | }, 0) catch continue; |
| ... | ... | @@ -184,9 +184,9 @@ pub const ElfDynLib = struct { |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | fn resolveFromParent(io: Io, dir_path: []const u8, file_name: []const u8) ?posix.fd_t { |
| 187 | var dir = std.fs.cwd().openDir(dir_path, .{}) catch return null; | |
| 187 | var dir = Io.Dir.cwd().openDir(dir_path, .{}) catch return null; | |
| 188 | 188 | defer dir.close(io); |
| 189 | return posix.openat(dir.fd, file_name, .{ | |
| 189 | return posix.openat(dir.handle, file_name, .{ | |
| 190 | 190 | .ACCMODE = .RDONLY, |
| 191 | 191 | .CLOEXEC = true, |
| 192 | 192 | }, 0) catch null; |
lib/std/fs/test.zig+54-62| ... | ... | @@ -46,7 +46,7 @@ const PathType = enum { |
| 46 | 46 | // The final path may not actually exist which would cause realpath to fail. |
| 47 | 47 | // So instead, we get the path of the dir and join it with the relative path. |
| 48 | 48 | var fd_path_buf: [fs.max_path_bytes]u8 = undefined; |
| 49 | const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf); | |
| 49 | const dir_path = try std.os.getFdPath(dir.handle, &fd_path_buf); | |
| 50 | 50 | return fs.path.joinZ(allocator, &.{ dir_path, relative_path }); |
| 51 | 51 | } |
| 52 | 52 | }.transform, |
| ... | ... | @@ -55,7 +55,7 @@ const PathType = enum { |
| 55 | 55 | // Any drive absolute path (C:\foo) can be converted into a UNC path by |
| 56 | 56 | // using '127.0.0.1' as the server name and '<drive letter>$' as the share name. |
| 57 | 57 | var fd_path_buf: [fs.max_path_bytes]u8 = undefined; |
| 58 | const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf); | |
| 58 | const dir_path = try std.os.getFdPath(dir.handle, &fd_path_buf); | |
| 59 | 59 | const windows_path_type = windows.getWin32PathType(u8, dir_path); |
| 60 | 60 | switch (windows_path_type) { |
| 61 | 61 | .unc_absolute => return fs.path.joinZ(allocator, &.{ dir_path, relative_path }), |
| ... | ... | @@ -256,7 +256,7 @@ fn testReadLinkW(allocator: mem.Allocator, dir: Dir, target_path: []const u8, sy |
| 256 | 256 | const target_path_w = try std.unicode.wtf8ToWtf16LeAlloc(allocator, target_path); |
| 257 | 257 | defer allocator.free(target_path_w); |
| 258 | 258 | // Calling the W functions directly requires the path to be NT-prefixed |
| 259 | const symlink_path_w = try std.os.windows.sliceToPrefixedFileW(dir.fd, symlink_path); | |
| 259 | const symlink_path_w = try std.os.windows.sliceToPrefixedFileW(dir.handle, symlink_path); | |
| 260 | 260 | const wtf16_buffer = try allocator.alloc(u16, target_path_w.len); |
| 261 | 261 | defer allocator.free(wtf16_buffer); |
| 262 | 262 | const actual = try dir.readLinkW(symlink_path_w.span(), wtf16_buffer); |
| ... | ... | @@ -288,9 +288,11 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { |
| 288 | 288 | |
| 289 | 289 | var symlink: Dir = switch (builtin.target.os.tag) { |
| 290 | 290 | .windows => windows_symlink: { |
| 291 | const sub_path_w = try windows.cStrToPrefixedFileW(ctx.dir.fd, "symlink"); | |
| 291 | const sub_path_w = try windows.cStrToPrefixedFileW(ctx.dir.handle, "symlink"); | |
| 292 | 292 | |
| 293 | var handle: windows.HANDLE = undefined; | |
| 293 | var result: Dir = .{ | |
| 294 | .handle = undefined, | |
| 295 | }; | |
| 294 | 296 | |
| 295 | 297 | const path_len_bytes = @as(u16, @intCast(sub_path_w.span().len * 2)); |
| 296 | 298 | var nt_name = windows.UNICODE_STRING{ |
| ... | ... | @@ -300,26 +302,16 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { |
| 300 | 302 | }; |
| 301 | 303 | var attr: windows.OBJECT_ATTRIBUTES = .{ |
| 302 | 304 | .Length = @sizeOf(windows.OBJECT_ATTRIBUTES), |
| 303 | .RootDirectory = if (fs.path.isAbsoluteWindowsW(sub_path_w.span())) null else ctx.dir.fd, | |
| 304 | .Attributes = .{}, | |
| 305 | .RootDirectory = if (fs.path.isAbsoluteWindowsW(sub_path_w.span())) null else ctx.dir.handle, | |
| 306 | .Attributes = 0, | |
| 305 | 307 | .ObjectName = &nt_name, |
| 306 | 308 | .SecurityDescriptor = null, |
| 307 | 309 | .SecurityQualityOfService = null, |
| 308 | 310 | }; |
| 309 | 311 | var io_status_block: windows.IO_STATUS_BLOCK = undefined; |
| 310 | 312 | const rc = windows.ntdll.NtCreateFile( |
| 311 | &handle, | |
| 312 | .{ | |
| 313 | .SPECIFIC = .{ .FILE_DIRECTORY = .{ | |
| 314 | .READ_EA = true, | |
| 315 | .TRAVERSE = true, | |
| 316 | .READ_ATTRIBUTES = true, | |
| 317 | } }, | |
| 318 | .STANDARD = .{ | |
| 319 | .RIGHTS = .READ, | |
| 320 | .SYNCHRONIZE = true, | |
| 321 | }, | |
| 322 | }, | |
| 313 | &result.handle, | |
| 314 | windows.STANDARD_RIGHTS_READ | windows.FILE_READ_ATTRIBUTES | windows.FILE_READ_EA | windows.SYNCHRONIZE | windows.FILE_TRAVERSE, | |
| 323 | 315 | &attr, |
| 324 | 316 | &io_status_block, |
| 325 | 317 | null, |
| ... | ... | @@ -337,7 +329,7 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { |
| 337 | 329 | ); |
| 338 | 330 | |
| 339 | 331 | switch (rc) { |
| 340 | .SUCCESS => break :windows_symlink .{ .fd = handle }, | |
| 332 | .SUCCESS => break :windows_symlink .{ .fd = result.handle }, | |
| 341 | 333 | else => return windows.unexpectedStatus(rc), |
| 342 | 334 | } |
| 343 | 335 | }, |
| ... | ... | @@ -351,8 +343,8 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { |
| 351 | 343 | .ACCMODE = .RDONLY, |
| 352 | 344 | .CLOEXEC = true, |
| 353 | 345 | }; |
| 354 | const fd = try posix.openatZ(ctx.dir.fd, &sub_path_c, flags, 0); | |
| 355 | break :linux_symlink Dir{ .fd = fd }; | |
| 346 | const fd = try posix.openatZ(ctx.dir.handle, &sub_path_c, flags, 0); | |
| 347 | break :linux_symlink .{ .handle = fd }; | |
| 356 | 348 | }, |
| 357 | 349 | else => unreachable, |
| 358 | 350 | }; |
| ... | ... | @@ -456,7 +448,7 @@ test "openDirAbsolute" { |
| 456 | 448 | test "openDir cwd parent '..'" { |
| 457 | 449 | const io = testing.io; |
| 458 | 450 | |
| 459 | var dir = fs.cwd().openDir("..", .{}) catch |err| { | |
| 451 | var dir = Io.Dir.cwd().openDir("..", .{}) catch |err| { | |
| 460 | 452 | if (native_os == .wasi and err == error.PermissionDenied) { |
| 461 | 453 | return; // This is okay. WASI disallows escaping from the fs sandbox |
| 462 | 454 | } |
| ... | ... | @@ -534,7 +526,7 @@ test "Dir.Iterator" { |
| 534 | 526 | defer tmp_dir.cleanup(); |
| 535 | 527 | |
| 536 | 528 | // First, create a couple of entries to iterate over. |
| 537 | const file = try tmp_dir.dir.createFile("some_file", .{}); | |
| 529 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); | |
| 538 | 530 | file.close(io); |
| 539 | 531 | |
| 540 | 532 | try tmp_dir.dir.makeDir("some_dir"); |
| ... | ... | @@ -570,7 +562,7 @@ test "Dir.Iterator many entries" { |
| 570 | 562 | var buf: [4]u8 = undefined; // Enough to store "1024". |
| 571 | 563 | while (i < num) : (i += 1) { |
| 572 | 564 | const name = try std.fmt.bufPrint(&buf, "{}", .{i}); |
| 573 | const file = try tmp_dir.dir.createFile(name, .{}); | |
| 565 | const file = try tmp_dir.dir.createFile(io, name, .{}); | |
| 574 | 566 | file.close(io); |
| 575 | 567 | } |
| 576 | 568 | |
| ... | ... | @@ -603,7 +595,7 @@ test "Dir.Iterator twice" { |
| 603 | 595 | defer tmp_dir.cleanup(); |
| 604 | 596 | |
| 605 | 597 | // First, create a couple of entries to iterate over. |
| 606 | const file = try tmp_dir.dir.createFile("some_file", .{}); | |
| 598 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); | |
| 607 | 599 | file.close(io); |
| 608 | 600 | |
| 609 | 601 | try tmp_dir.dir.makeDir("some_dir"); |
| ... | ... | @@ -638,7 +630,7 @@ test "Dir.Iterator reset" { |
| 638 | 630 | defer tmp_dir.cleanup(); |
| 639 | 631 | |
| 640 | 632 | // First, create a couple of entries to iterate over. |
| 641 | const file = try tmp_dir.dir.createFile("some_file", .{}); | |
| 633 | const file = try tmp_dir.dir.createFile(io, "some_file", .{}); | |
| 642 | 634 | file.close(io); |
| 643 | 635 | |
| 644 | 636 | try tmp_dir.dir.makeDir("some_dir"); |
| ... | ... | @@ -769,7 +761,7 @@ test "readFileAlloc" { |
| 769 | 761 | var tmp_dir = tmpDir(.{}); |
| 770 | 762 | defer tmp_dir.cleanup(); |
| 771 | 763 | |
| 772 | var file = try tmp_dir.dir.createFile("test_file", .{ .read = true }); | |
| 764 | var file = try tmp_dir.dir.createFile(io, "test_file", .{ .read = true }); | |
| 773 | 765 | defer file.close(io); |
| 774 | 766 | |
| 775 | 767 | const buf1 = try tmp_dir.dir.readFileAlloc("test_file", testing.allocator, .limited(1024)); |
| ... | ... | @@ -843,7 +835,7 @@ test "directory operations on files" { |
| 843 | 835 | |
| 844 | 836 | const test_file_name = try ctx.transformPath("test_file"); |
| 845 | 837 | |
| 846 | var file = try ctx.dir.createFile(test_file_name, .{ .read = true }); | |
| 838 | var file = try ctx.dir.createFile(io, test_file_name, .{ .read = true }); | |
| 847 | 839 | file.close(io); |
| 848 | 840 | |
| 849 | 841 | try testing.expectError(error.PathAlreadyExists, ctx.dir.makeDir(test_file_name)); |
| ... | ... | @@ -876,7 +868,7 @@ test "file operations on directories" { |
| 876 | 868 | |
| 877 | 869 | try ctx.dir.makeDir(test_dir_name); |
| 878 | 870 | |
| 879 | try testing.expectError(error.IsDir, ctx.dir.createFile(test_dir_name, .{})); | |
| 871 | try testing.expectError(error.IsDir, ctx.dir.createFile(io, test_dir_name, .{})); | |
| 880 | 872 | try testing.expectError(error.IsDir, ctx.dir.deleteFile(test_dir_name)); |
| 881 | 873 | switch (native_os) { |
| 882 | 874 | .dragonfly, .netbsd => { |
| ... | ... | @@ -969,7 +961,7 @@ test "Dir.rename files" { |
| 969 | 961 | // Renaming files |
| 970 | 962 | const test_file_name = try ctx.transformPath("test_file"); |
| 971 | 963 | const renamed_test_file_name = try ctx.transformPath("test_file_renamed"); |
| 972 | var file = try ctx.dir.createFile(test_file_name, .{ .read = true }); | |
| 964 | var file = try ctx.dir.createFile(io, test_file_name, .{ .read = true }); | |
| 973 | 965 | file.close(io); |
| 974 | 966 | try ctx.dir.rename(test_file_name, renamed_test_file_name); |
| 975 | 967 | |
| ... | ... | @@ -983,7 +975,7 @@ test "Dir.rename files" { |
| 983 | 975 | |
| 984 | 976 | // Rename to existing file succeeds |
| 985 | 977 | const existing_file_path = try ctx.transformPath("existing_file"); |
| 986 | var existing_file = try ctx.dir.createFile(existing_file_path, .{ .read = true }); | |
| 978 | var existing_file = try ctx.dir.createFile(io, existing_file_path, .{ .read = true }); | |
| 987 | 979 | existing_file.close(io); |
| 988 | 980 | try ctx.dir.rename(renamed_test_file_name, existing_file_path); |
| 989 | 981 | |
| ... | ... | @@ -1017,7 +1009,7 @@ test "Dir.rename directories" { |
| 1017 | 1009 | var dir = try ctx.dir.openDir(test_dir_renamed_path, .{}); |
| 1018 | 1010 | |
| 1019 | 1011 | // Put a file in the directory |
| 1020 | var file = try dir.createFile("test_file", .{ .read = true }); | |
| 1012 | var file = try dir.createFile(io, "test_file", .{ .read = true }); | |
| 1021 | 1013 | file.close(io); |
| 1022 | 1014 | dir.close(io); |
| 1023 | 1015 | |
| ... | ... | @@ -1070,7 +1062,7 @@ test "Dir.rename directory onto non-empty dir" { |
| 1070 | 1062 | try ctx.dir.makeDir(test_dir_path); |
| 1071 | 1063 | |
| 1072 | 1064 | var target_dir = try ctx.dir.makeOpenPath(target_dir_path, .{}); |
| 1073 | var file = try target_dir.createFile("test_file", .{ .read = true }); | |
| 1065 | var file = try target_dir.createFile(io, "test_file", .{ .read = true }); | |
| 1074 | 1066 | file.close(io); |
| 1075 | 1067 | target_dir.close(io); |
| 1076 | 1068 | |
| ... | ... | @@ -1094,7 +1086,7 @@ test "Dir.rename file <-> dir" { |
| 1094 | 1086 | const test_file_path = try ctx.transformPath("test_file"); |
| 1095 | 1087 | const test_dir_path = try ctx.transformPath("test_dir"); |
| 1096 | 1088 | |
| 1097 | var file = try ctx.dir.createFile(test_file_path, .{ .read = true }); | |
| 1089 | var file = try ctx.dir.createFile(io, test_file_path, .{ .read = true }); | |
| 1098 | 1090 | file.close(io); |
| 1099 | 1091 | try ctx.dir.makeDir(test_dir_path); |
| 1100 | 1092 | try testing.expectError(error.IsDir, ctx.dir.rename(test_file_path, test_dir_path)); |
| ... | ... | @@ -1115,7 +1107,7 @@ test "rename" { |
| 1115 | 1107 | // Renaming files |
| 1116 | 1108 | const test_file_name = "test_file"; |
| 1117 | 1109 | const renamed_test_file_name = "test_file_renamed"; |
| 1118 | var file = try tmp_dir1.dir.createFile(test_file_name, .{ .read = true }); | |
| 1110 | var file = try tmp_dir1.dir.createFile(io, test_file_name, .{ .read = true }); | |
| 1119 | 1111 | file.close(io); |
| 1120 | 1112 | try fs.rename(tmp_dir1.dir, test_file_name, tmp_dir2.dir, renamed_test_file_name); |
| 1121 | 1113 | |
| ... | ... | @@ -1149,7 +1141,7 @@ test "renameAbsolute" { |
| 1149 | 1141 | // Renaming files |
| 1150 | 1142 | const test_file_name = "test_file"; |
| 1151 | 1143 | const renamed_test_file_name = "test_file_renamed"; |
| 1152 | var file = try tmp_dir.dir.createFile(test_file_name, .{ .read = true }); | |
| 1144 | var file = try tmp_dir.dir.createFile(io, test_file_name, .{ .read = true }); | |
| 1153 | 1145 | file.close(io); |
| 1154 | 1146 | try fs.renameAbsolute( |
| 1155 | 1147 | try fs.path.join(allocator, &.{ base_path, test_file_name }), |
| ... | ... | @@ -1454,7 +1446,7 @@ test "writev, readv" { |
| 1454 | 1446 | var write_vecs: [2][]const u8 = .{ line1, line2 }; |
| 1455 | 1447 | var read_vecs: [2][]u8 = .{ &buf2, &buf1 }; |
| 1456 | 1448 | |
| 1457 | var src_file = try tmp.dir.createFile("test.txt", .{ .read = true }); | |
| 1449 | var src_file = try tmp.dir.createFile(io, "test.txt", .{ .read = true }); | |
| 1458 | 1450 | defer src_file.close(io); |
| 1459 | 1451 | |
| 1460 | 1452 | var writer = src_file.writerStreaming(&.{}); |
| ... | ... | @@ -1484,7 +1476,7 @@ test "pwritev, preadv" { |
| 1484 | 1476 | var buf2: [line2.len]u8 = undefined; |
| 1485 | 1477 | var read_vecs: [2][]u8 = .{ &buf2, &buf1 }; |
| 1486 | 1478 | |
| 1487 | var src_file = try tmp.dir.createFile("test.txt", .{ .read = true }); | |
| 1479 | var src_file = try tmp.dir.createFile(io, "test.txt", .{ .read = true }); | |
| 1488 | 1480 | defer src_file.close(io); |
| 1489 | 1481 | |
| 1490 | 1482 | var writer = src_file.writer(&.{}); |
| ... | ... | @@ -1584,14 +1576,14 @@ test "sendfile" { |
| 1584 | 1576 | const line2 = "second line\n"; |
| 1585 | 1577 | var vecs = [_][]const u8{ line1, line2 }; |
| 1586 | 1578 | |
| 1587 | var src_file = try dir.createFile("sendfile1.txt", .{ .read = true }); | |
| 1579 | var src_file = try dir.createFile(io, "sendfile1.txt", .{ .read = true }); | |
| 1588 | 1580 | defer src_file.close(io); |
| 1589 | 1581 | { |
| 1590 | 1582 | var fw = src_file.writer(&.{}); |
| 1591 | 1583 | try fw.interface.writeVecAll(&vecs); |
| 1592 | 1584 | } |
| 1593 | 1585 | |
| 1594 | var dest_file = try dir.createFile("sendfile2.txt", .{ .read = true }); | |
| 1586 | var dest_file = try dir.createFile(io, "sendfile2.txt", .{ .read = true }); | |
| 1595 | 1587 | defer dest_file.close(io); |
| 1596 | 1588 | |
| 1597 | 1589 | const header1 = "header1\n"; |
| ... | ... | @@ -1627,12 +1619,12 @@ test "sendfile with buffered data" { |
| 1627 | 1619 | var dir = try tmp.dir.openDir("os_test_tmp", .{}); |
| 1628 | 1620 | defer dir.close(io); |
| 1629 | 1621 | |
| 1630 | var src_file = try dir.createFile("sendfile1.txt", .{ .read = true }); | |
| 1622 | var src_file = try dir.createFile(io, "sendfile1.txt", .{ .read = true }); | |
| 1631 | 1623 | defer src_file.close(io); |
| 1632 | 1624 | |
| 1633 | 1625 | try src_file.writeAll("AAAABBBB"); |
| 1634 | 1626 | |
| 1635 | var dest_file = try dir.createFile("sendfile2.txt", .{ .read = true }); | |
| 1627 | var dest_file = try dir.createFile(io, "sendfile2.txt", .{ .read = true }); | |
| 1636 | 1628 | defer dest_file.close(io); |
| 1637 | 1629 | |
| 1638 | 1630 | var src_buffer: [32]u8 = undefined; |
| ... | ... | @@ -1718,10 +1710,10 @@ test "open file with exclusive nonblocking lock twice" { |
| 1718 | 1710 | const io = ctx.io; |
| 1719 | 1711 | const filename = try ctx.transformPath("file_nonblocking_lock_test.txt"); |
| 1720 | 1712 | |
| 1721 | const file1 = try ctx.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1713 | const file1 = try ctx.dir.createFile(io, filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1722 | 1714 | defer file1.close(io); |
| 1723 | 1715 | |
| 1724 | const file2 = ctx.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1716 | const file2 = ctx.dir.createFile(io, filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1725 | 1717 | try testing.expectError(error.WouldBlock, file2); |
| 1726 | 1718 | } |
| 1727 | 1719 | }.impl); |
| ... | ... | @@ -1735,10 +1727,10 @@ test "open file with shared and exclusive nonblocking lock" { |
| 1735 | 1727 | const io = ctx.io; |
| 1736 | 1728 | const filename = try ctx.transformPath("file_nonblocking_lock_test.txt"); |
| 1737 | 1729 | |
| 1738 | const file1 = try ctx.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true }); | |
| 1730 | const file1 = try ctx.dir.createFile(io, filename, .{ .lock = .shared, .lock_nonblocking = true }); | |
| 1739 | 1731 | defer file1.close(io); |
| 1740 | 1732 | |
| 1741 | const file2 = ctx.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1733 | const file2 = ctx.dir.createFile(io, filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1742 | 1734 | try testing.expectError(error.WouldBlock, file2); |
| 1743 | 1735 | } |
| 1744 | 1736 | }.impl); |
| ... | ... | @@ -1752,10 +1744,10 @@ test "open file with exclusive and shared nonblocking lock" { |
| 1752 | 1744 | const io = ctx.io; |
| 1753 | 1745 | const filename = try ctx.transformPath("file_nonblocking_lock_test.txt"); |
| 1754 | 1746 | |
| 1755 | const file1 = try ctx.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1747 | const file1 = try ctx.dir.createFile(io, filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1756 | 1748 | defer file1.close(io); |
| 1757 | 1749 | |
| 1758 | const file2 = ctx.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true }); | |
| 1750 | const file2 = ctx.dir.createFile(io, filename, .{ .lock = .shared, .lock_nonblocking = true }); | |
| 1759 | 1751 | try testing.expectError(error.WouldBlock, file2); |
| 1760 | 1752 | } |
| 1761 | 1753 | }.impl); |
| ... | ... | @@ -1769,13 +1761,13 @@ test "open file with exclusive lock twice, make sure second lock waits" { |
| 1769 | 1761 | const io = ctx.io; |
| 1770 | 1762 | const filename = try ctx.transformPath("file_lock_test.txt"); |
| 1771 | 1763 | |
| 1772 | const file = try ctx.dir.createFile(filename, .{ .lock = .exclusive }); | |
| 1764 | const file = try ctx.dir.createFile(io, filename, .{ .lock = .exclusive }); | |
| 1773 | 1765 | errdefer file.close(io); |
| 1774 | 1766 | |
| 1775 | 1767 | const S = struct { |
| 1776 | 1768 | fn checkFn(dir: *Io.Dir, path: []const u8, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void { |
| 1777 | 1769 | started.set(); |
| 1778 | const file1 = try dir.createFile(path, .{ .lock = .exclusive }); | |
| 1770 | const file1 = try dir.createFile(io, path, .{ .lock = .exclusive }); | |
| 1779 | 1771 | |
| 1780 | 1772 | locked.set(); |
| 1781 | 1773 | file1.close(io); |
| ... | ... | @@ -1847,13 +1839,13 @@ test "read from locked file" { |
| 1847 | 1839 | const filename = try ctx.transformPath("read_lock_file_test.txt"); |
| 1848 | 1840 | |
| 1849 | 1841 | { |
| 1850 | const f = try ctx.dir.createFile(filename, .{ .read = true }); | |
| 1842 | const f = try ctx.dir.createFile(io, filename, .{ .read = true }); | |
| 1851 | 1843 | defer f.close(io); |
| 1852 | 1844 | var buffer: [1]u8 = undefined; |
| 1853 | 1845 | _ = try f.read(&buffer); |
| 1854 | 1846 | } |
| 1855 | 1847 | { |
| 1856 | const f = try ctx.dir.createFile(filename, .{ | |
| 1848 | const f = try ctx.dir.createFile(io, filename, .{ | |
| 1857 | 1849 | .read = true, |
| 1858 | 1850 | .lock = .exclusive, |
| 1859 | 1851 | }); |
| ... | ... | @@ -2037,7 +2029,7 @@ test "'.' and '..' in Io.Dir functions" { |
| 2037 | 2029 | var created_subdir = try ctx.dir.openDir(subdir_path, .{}); |
| 2038 | 2030 | created_subdir.close(io); |
| 2039 | 2031 | |
| 2040 | const created_file = try ctx.dir.createFile(file_path, .{}); | |
| 2032 | const created_file = try ctx.dir.createFile(io, file_path, .{}); | |
| 2041 | 2033 | created_file.close(io); |
| 2042 | 2034 | try ctx.dir.access(file_path, .{}); |
| 2043 | 2035 | |
| ... | ... | @@ -2103,7 +2095,7 @@ test "chmod" { |
| 2103 | 2095 | var tmp = tmpDir(.{}); |
| 2104 | 2096 | defer tmp.cleanup(); |
| 2105 | 2097 | |
| 2106 | const file = try tmp.dir.createFile("test_file", .{ .mode = 0o600 }); | |
| 2098 | const file = try tmp.dir.createFile(io, "test_file", .{ .mode = 0o600 }); | |
| 2107 | 2099 | defer file.close(io); |
| 2108 | 2100 | try testing.expectEqual(@as(File.Mode, 0o600), (try file.stat()).mode & 0o7777); |
| 2109 | 2101 | |
| ... | ... | @@ -2127,7 +2119,7 @@ test "chown" { |
| 2127 | 2119 | var tmp = tmpDir(.{}); |
| 2128 | 2120 | defer tmp.cleanup(); |
| 2129 | 2121 | |
| 2130 | const file = try tmp.dir.createFile("test_file", .{}); | |
| 2122 | const file = try tmp.dir.createFile(io, "test_file", .{}); | |
| 2131 | 2123 | defer file.close(io); |
| 2132 | 2124 | try file.chown(null, null); |
| 2133 | 2125 | |
| ... | ... | @@ -2228,7 +2220,7 @@ test "read file non vectored" { |
| 2228 | 2220 | |
| 2229 | 2221 | const contents = "hello, world!\n"; |
| 2230 | 2222 | |
| 2231 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); | |
| 2223 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); | |
| 2232 | 2224 | defer file.close(io); |
| 2233 | 2225 | { |
| 2234 | 2226 | var file_writer: File.Writer = .init(file, &.{}); |
| ... | ... | @@ -2260,7 +2252,7 @@ test "seek keeping partial buffer" { |
| 2260 | 2252 | |
| 2261 | 2253 | const contents = "0123456789"; |
| 2262 | 2254 | |
| 2263 | const file = try tmp_dir.dir.createFile("input.txt", .{ .read = true }); | |
| 2255 | const file = try tmp_dir.dir.createFile(io, "input.txt", .{ .read = true }); | |
| 2264 | 2256 | defer file.close(io); |
| 2265 | 2257 | { |
| 2266 | 2258 | var file_writer: File.Writer = .init(file, &.{}); |
| ... | ... | @@ -2321,7 +2313,7 @@ test "seekTo flushes buffered data" { |
| 2321 | 2313 | |
| 2322 | 2314 | const contents = "data"; |
| 2323 | 2315 | |
| 2324 | const file = try tmp.dir.createFile("seek.bin", .{ .read = true }); | |
| 2316 | const file = try tmp.dir.createFile(io, "seek.bin", .{ .read = true }); | |
| 2325 | 2317 | defer file.close(io); |
| 2326 | 2318 | { |
| 2327 | 2319 | var buf: [16]u8 = undefined; |
| ... | ... | @@ -2350,7 +2342,7 @@ test "File.Writer sendfile with buffered contents" { |
| 2350 | 2342 | try tmp_dir.dir.writeFile(.{ .sub_path = "a", .data = "bcd" }); |
| 2351 | 2343 | const in = try tmp_dir.dir.openFile(io, "a", .{}); |
| 2352 | 2344 | defer in.close(io); |
| 2353 | const out = try tmp_dir.dir.createFile("b", .{}); | |
| 2345 | const out = try tmp_dir.dir.createFile(io, "b", .{}); | |
| 2354 | 2346 | defer out.close(io); |
| 2355 | 2347 | |
| 2356 | 2348 | var in_buf: [2]u8 = undefined; |
| ... | ... | @@ -2397,7 +2389,7 @@ test "readlinkat" { |
| 2397 | 2389 | // create a symbolic link |
| 2398 | 2390 | if (native_os == .windows) { |
| 2399 | 2391 | std.os.windows.CreateSymbolicLink( |
| 2400 | tmp.dir.fd, | |
| 2392 | tmp.dir.handle, | |
| 2401 | 2393 | &[_]u16{ 'l', 'i', 'n', 'k' }, |
| 2402 | 2394 | &[_:0]u16{ 'f', 'i', 'l', 'e', '.', 't', 'x', 't' }, |
| 2403 | 2395 | false, |
| ... | ... | @@ -2407,7 +2399,7 @@ test "readlinkat" { |
| 2407 | 2399 | else => return err, |
| 2408 | 2400 | }; |
| 2409 | 2401 | } else { |
| 2410 | try posix.symlinkat("file.txt", tmp.dir.fd, "link"); | |
| 2402 | try posix.symlinkat("file.txt", tmp.dir.handle, "link"); | |
| 2411 | 2403 | } |
| 2412 | 2404 | |
| 2413 | 2405 | // read the link |
lib/std/os/linux/IoUring.zig+12-12| ... | ... | @@ -1991,7 +1991,7 @@ test "writev/fsync/readv" { |
| 1991 | 1991 | defer tmp.cleanup(); |
| 1992 | 1992 | |
| 1993 | 1993 | const path = "test_io_uring_writev_fsync_readv"; |
| 1994 | const file = try tmp.dir.createFile(path, .{ .read = true, .truncate = true }); | |
| 1994 | const file = try tmp.dir.createFile(io, path, .{ .read = true, .truncate = true }); | |
| 1995 | 1995 | defer file.close(io); |
| 1996 | 1996 | const fd = file.handle; |
| 1997 | 1997 | |
| ... | ... | @@ -2062,7 +2062,7 @@ test "write/read" { |
| 2062 | 2062 | var tmp = std.testing.tmpDir(.{}); |
| 2063 | 2063 | defer tmp.cleanup(); |
| 2064 | 2064 | const path = "test_io_uring_write_read"; |
| 2065 | const file = try tmp.dir.createFile(path, .{ .read = true, .truncate = true }); | |
| 2065 | const file = try tmp.dir.createFile(io, path, .{ .read = true, .truncate = true }); | |
| 2066 | 2066 | defer file.close(io); |
| 2067 | 2067 | const fd = file.handle; |
| 2068 | 2068 | |
| ... | ... | @@ -2110,12 +2110,12 @@ test "splice/read" { |
| 2110 | 2110 | |
| 2111 | 2111 | var tmp = std.testing.tmpDir(.{}); |
| 2112 | 2112 | const path_src = "test_io_uring_splice_src"; |
| 2113 | const file_src = try tmp.dir.createFile(path_src, .{ .read = true, .truncate = true }); | |
| 2113 | const file_src = try tmp.dir.createFile(io, path_src, .{ .read = true, .truncate = true }); | |
| 2114 | 2114 | defer file_src.close(io); |
| 2115 | 2115 | const fd_src = file_src.handle; |
| 2116 | 2116 | |
| 2117 | 2117 | const path_dst = "test_io_uring_splice_dst"; |
| 2118 | const file_dst = try tmp.dir.createFile(path_dst, .{ .read = true, .truncate = true }); | |
| 2118 | const file_dst = try tmp.dir.createFile(io, path_dst, .{ .read = true, .truncate = true }); | |
| 2119 | 2119 | defer file_dst.close(io); |
| 2120 | 2120 | const fd_dst = file_dst.handle; |
| 2121 | 2121 | |
| ... | ... | @@ -2185,7 +2185,7 @@ test "write_fixed/read_fixed" { |
| 2185 | 2185 | defer tmp.cleanup(); |
| 2186 | 2186 | |
| 2187 | 2187 | const path = "test_io_uring_write_read_fixed"; |
| 2188 | const file = try tmp.dir.createFile(path, .{ .read = true, .truncate = true }); | |
| 2188 | const file = try tmp.dir.createFile(io, path, .{ .read = true, .truncate = true }); | |
| 2189 | 2189 | defer file.close(io); |
| 2190 | 2190 | const fd = file.handle; |
| 2191 | 2191 | |
| ... | ... | @@ -2306,7 +2306,7 @@ test "close" { |
| 2306 | 2306 | defer tmp.cleanup(); |
| 2307 | 2307 | |
| 2308 | 2308 | const path = "test_io_uring_close"; |
| 2309 | const file = try tmp.dir.createFile(path, .{}); | |
| 2309 | const file = try tmp.dir.createFile(io, path, .{}); | |
| 2310 | 2310 | errdefer file.close(io); |
| 2311 | 2311 | |
| 2312 | 2312 | const sqe_close = try ring.close(0x44444444, file.handle); |
| ... | ... | @@ -2652,7 +2652,7 @@ test "fallocate" { |
| 2652 | 2652 | defer tmp.cleanup(); |
| 2653 | 2653 | |
| 2654 | 2654 | const path = "test_io_uring_fallocate"; |
| 2655 | const file = try tmp.dir.createFile(path, .{ .truncate = true, .mode = 0o666 }); | |
| 2655 | const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 }); | |
| 2656 | 2656 | defer file.close(io); |
| 2657 | 2657 | |
| 2658 | 2658 | try testing.expectEqual(@as(u64, 0), (try file.stat()).size); |
| ... | ... | @@ -2699,7 +2699,7 @@ test "statx" { |
| 2699 | 2699 | var tmp = std.testing.tmpDir(.{}); |
| 2700 | 2700 | defer tmp.cleanup(); |
| 2701 | 2701 | const path = "test_io_uring_statx"; |
| 2702 | const file = try tmp.dir.createFile(path, .{ .truncate = true, .mode = 0o666 }); | |
| 2702 | const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 }); | |
| 2703 | 2703 | defer file.close(io); |
| 2704 | 2704 | |
| 2705 | 2705 | try testing.expectEqual(@as(u64, 0), (try file.stat()).size); |
| ... | ... | @@ -2969,7 +2969,7 @@ test "renameat" { |
| 2969 | 2969 | |
| 2970 | 2970 | // Write old file with data |
| 2971 | 2971 | |
| 2972 | const old_file = try tmp.dir.createFile(old_path, .{ .truncate = true, .mode = 0o666 }); | |
| 2972 | const old_file = try tmp.dir.createFile(io, old_path, .{ .truncate = true, .mode = 0o666 }); | |
| 2973 | 2973 | defer old_file.close(io); |
| 2974 | 2974 | try old_file.writeAll("hello"); |
| 2975 | 2975 | |
| ... | ... | @@ -3028,7 +3028,7 @@ test "unlinkat" { |
| 3028 | 3028 | |
| 3029 | 3029 | // Write old file with data |
| 3030 | 3030 | |
| 3031 | const file = try tmp.dir.createFile(path, .{ .truncate = true, .mode = 0o666 }); | |
| 3031 | const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 }); | |
| 3032 | 3032 | defer file.close(io); |
| 3033 | 3033 | |
| 3034 | 3034 | // Submit unlinkat |
| ... | ... | @@ -3125,7 +3125,7 @@ test "symlinkat" { |
| 3125 | 3125 | const path = "test_io_uring_symlinkat"; |
| 3126 | 3126 | const link_path = "test_io_uring_symlinkat_link"; |
| 3127 | 3127 | |
| 3128 | const file = try tmp.dir.createFile(path, .{ .truncate = true, .mode = 0o666 }); | |
| 3128 | const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 }); | |
| 3129 | 3129 | defer file.close(io); |
| 3130 | 3130 | |
| 3131 | 3131 | // Submit symlinkat |
| ... | ... | @@ -3177,7 +3177,7 @@ test "linkat" { |
| 3177 | 3177 | |
| 3178 | 3178 | // Write file with data |
| 3179 | 3179 | |
| 3180 | const first_file = try tmp.dir.createFile(first_path, .{ .truncate = true, .mode = 0o666 }); | |
| 3180 | const first_file = try tmp.dir.createFile(io, first_path, .{ .truncate = true, .mode = 0o666 }); | |
| 3181 | 3181 | defer first_file.close(io); |
| 3182 | 3182 | try first_file.writeAll("hello"); |
| 3183 | 3183 |
lib/std/os/linux/test.zig+3-3| ... | ... | @@ -18,7 +18,7 @@ test "fallocate" { |
| 18 | 18 | defer tmp.cleanup(); |
| 19 | 19 | |
| 20 | 20 | const path = "test_fallocate"; |
| 21 | const file = try tmp.dir.createFile(path, .{ .truncate = true, .mode = 0o666 }); | |
| 21 | const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .mode = 0o666 }); | |
| 22 | 22 | defer file.close(io); |
| 23 | 23 | |
| 24 | 24 | try expect((try file.stat()).size == 0); |
| ... | ... | @@ -85,7 +85,7 @@ test "statx" { |
| 85 | 85 | defer tmp.cleanup(); |
| 86 | 86 | |
| 87 | 87 | const tmp_file_name = "just_a_temporary_file.txt"; |
| 88 | var file = try tmp.dir.createFile(tmp_file_name, .{}); | |
| 88 | var file = try tmp.dir.createFile(io, tmp_file_name, .{}); | |
| 89 | 89 | defer file.close(io); |
| 90 | 90 | |
| 91 | 91 | var buf: linux.Statx = undefined; |
| ... | ... | @@ -121,7 +121,7 @@ test "fadvise" { |
| 121 | 121 | defer tmp.cleanup(); |
| 122 | 122 | |
| 123 | 123 | const tmp_file_name = "temp_posix_fadvise.txt"; |
| 124 | var file = try tmp.dir.createFile(tmp_file_name, .{}); | |
| 124 | var file = try tmp.dir.createFile(io, tmp_file_name, .{}); | |
| 125 | 125 | defer file.close(io); |
| 126 | 126 | |
| 127 | 127 | var buf: [2048]u8 = undefined; |
lib/std/os/windows.zig+2-2| ... | ... | @@ -4639,8 +4639,8 @@ pub fn wToPrefixedFileW(dir: ?HANDLE, path: [:0]const u16) Wtf16ToPrefixedFileWE |
| 4639 | 4639 | break :path_to_get path; |
| 4640 | 4640 | } |
| 4641 | 4641 | // We can also skip GetFinalPathNameByHandle if the handle matches |
| 4642 | // the handle returned by fs.cwd() | |
| 4643 | if (dir.? == std.fs.cwd().fd) { | |
| 4642 | // the handle returned by Io.Dir.cwd() | |
| 4643 | if (dir.? == Io.Dir.cwd().fd) { | |
| 4644 | 4644 | break :path_to_get path; |
| 4645 | 4645 | } |
| 4646 | 4646 | // At this point, we know we have a relative path that had too many |
lib/std/posix.zig+7-7| ... | ... | @@ -15,15 +15,16 @@ |
| 15 | 15 | //! deal with the exception. |
| 16 | 16 | |
| 17 | 17 | const builtin = @import("builtin"); |
| 18 | const root = @import("root"); | |
| 18 | const native_os = builtin.os.tag; | |
| 19 | ||
| 19 | 20 | const std = @import("std.zig"); |
| 21 | const Io = std.Io; | |
| 20 | 22 | const mem = std.mem; |
| 21 | 23 | const fs = std.fs; |
| 22 | const max_path_bytes = fs.max_path_bytes; | |
| 24 | const max_path_bytes = std.fs.max_path_bytes; | |
| 23 | 25 | const maxInt = std.math.maxInt; |
| 24 | 26 | const cast = std.math.cast; |
| 25 | 27 | const assert = std.debug.assert; |
| 26 | const native_os = builtin.os.tag; | |
| 27 | 28 | const page_size_min = std.heap.page_size_min; |
| 28 | 29 | |
| 29 | 30 | test { |
| ... | ... | @@ -797,7 +798,6 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 797 | 798 | .INTR => continue, |
| 798 | 799 | .INVAL => unreachable, |
| 799 | 800 | .FAULT => unreachable, |
| 800 | .SRCH => return error.ProcessNotFound, | |
| 801 | 801 | .AGAIN => return error.WouldBlock, |
| 802 | 802 | .CANCELED => return error.Canceled, |
| 803 | 803 | .BADF => return error.NotOpenForReading, // Can be a race condition. |
| ... | ... | @@ -917,7 +917,6 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 917 | 917 | .INTR => continue, |
| 918 | 918 | .INVAL => return error.InvalidArgument, |
| 919 | 919 | .FAULT => unreachable, |
| 920 | .SRCH => return error.ProcessNotFound, | |
| 921 | 920 | .AGAIN => return error.WouldBlock, |
| 922 | 921 | .BADF => return error.NotOpenForWriting, // can be a race condition. |
| 923 | 922 | .DESTADDRREQ => unreachable, // `connect` was never called. |
| ... | ... | @@ -985,7 +984,8 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t { |
| 985 | 984 | .NFILE => return error.SystemFdQuotaExceeded, |
| 986 | 985 | .NODEV => return error.NoDevice, |
| 987 | 986 | .NOENT => return error.FileNotFound, |
| 988 | .SRCH => return error.ProcessNotFound, | |
| 987 | // Can happen on Linux when opening procfs files. | |
| 988 | .SRCH => return error.FileNotFound, | |
| 989 | 989 | .NOMEM => return error.SystemResources, |
| 990 | 990 | .NOSPC => return error.NoSpaceLeft, |
| 991 | 991 | .NOTDIR => return error.NotDir, |
| ... | ... | @@ -1560,7 +1560,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: mode_t) MakeDirError!void { |
| 1560 | 1560 | pub fn mkdirW(dir_path_w: []const u16, mode: mode_t) MakeDirError!void { |
| 1561 | 1561 | _ = mode; |
| 1562 | 1562 | const sub_dir_handle = windows.OpenFile(dir_path_w, .{ |
| 1563 | .dir = fs.cwd().fd, | |
| 1563 | .dir = Io.Dir.cwd().handle, | |
| 1564 | 1564 | .access_mask = .{ |
| 1565 | 1565 | .STANDARD = .{ .SYNCHRONIZE = true }, |
| 1566 | 1566 | .GENERIC = .{ .READ = true }, |
lib/std/posix/test.zig+26-26| ... | ... | @@ -148,7 +148,7 @@ test "linkat with different directories" { |
| 148 | 148 | try tmp.dir.writeFile(.{ .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 | try posix.linkat(tmp.dir.fd, target_name, subdir.fd, link_name, 0); | |
| 151 | try posix.linkat(tmp.dir.handle, target_name, subdir.handle, link_name, 0); | |
| 152 | 152 | |
| 153 | 153 | const efd = try tmp.dir.openFile(io, target_name, .{}); |
| 154 | 154 | defer efd.close(io); |
| ... | ... | @@ -164,7 +164,7 @@ test "linkat with different directories" { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Test 2: remove link |
| 167 | try posix.unlinkat(subdir.fd, link_name, 0); | |
| 167 | try posix.unlinkat(subdir.handle, link_name, 0); | |
| 168 | 168 | _, const elink = try getLinkInfo(efd.handle); |
| 169 | 169 | try testing.expectEqual(@as(posix.nlink_t, 1), elink); |
| 170 | 170 | } |
| ... | ... | @@ -373,7 +373,7 @@ test "mmap" { |
| 373 | 373 | |
| 374 | 374 | // Create a file used for testing mmap() calls with a file descriptor |
| 375 | 375 | { |
| 376 | const file = try tmp.dir.createFile(test_out_file, .{}); | |
| 376 | const file = try tmp.dir.createFile(io, test_out_file, .{}); | |
| 377 | 377 | defer file.close(io); |
| 378 | 378 | |
| 379 | 379 | var stream = file.writer(&.{}); |
| ... | ... | @@ -444,7 +444,7 @@ test "fcntl" { |
| 444 | 444 | |
| 445 | 445 | const test_out_file = "os_tmp_test"; |
| 446 | 446 | |
| 447 | const file = try tmp.dir.createFile(test_out_file, .{}); | |
| 447 | const file = try tmp.dir.createFile(io, test_out_file, .{}); | |
| 448 | 448 | defer file.close(io); |
| 449 | 449 | |
| 450 | 450 | // Note: The test assumes createFile opens the file with CLOEXEC |
| ... | ... | @@ -495,7 +495,7 @@ test "fsync" { |
| 495 | 495 | defer tmp.cleanup(); |
| 496 | 496 | |
| 497 | 497 | const test_out_file = "os_tmp_test"; |
| 498 | const file = try tmp.dir.createFile(test_out_file, .{}); | |
| 498 | const file = try tmp.dir.createFile(io, test_out_file, .{}); | |
| 499 | 499 | defer file.close(io); |
| 500 | 500 | |
| 501 | 501 | try posix.fsync(file.handle); |
| ... | ... | @@ -617,7 +617,7 @@ test "dup & dup2" { |
| 617 | 617 | defer tmp.cleanup(); |
| 618 | 618 | |
| 619 | 619 | { |
| 620 | var file = try tmp.dir.createFile("os_dup_test", .{}); | |
| 620 | var file = try tmp.dir.createFile(io, "os_dup_test", .{}); | |
| 621 | 621 | defer file.close(io); |
| 622 | 622 | |
| 623 | 623 | var duped = Io.File{ .handle = try posix.dup(file.handle) }; |
| ... | ... | @@ -659,7 +659,7 @@ test "writev longer than IOV_MAX" { |
| 659 | 659 | var tmp = tmpDir(.{}); |
| 660 | 660 | defer tmp.cleanup(); |
| 661 | 661 | |
| 662 | var file = try tmp.dir.createFile("pwritev", .{}); | |
| 662 | var file = try tmp.dir.createFile(io, "pwritev", .{}); | |
| 663 | 663 | defer file.close(io); |
| 664 | 664 | |
| 665 | 665 | const iovecs = [_]posix.iovec_const{.{ .base = "a", .len = 1 }} ** (posix.IOV_MAX + 1); |
| ... | ... | @@ -684,7 +684,7 @@ test "POSIX file locking with fcntl" { |
| 684 | 684 | defer tmp.cleanup(); |
| 685 | 685 | |
| 686 | 686 | // Create a temporary lock file |
| 687 | var file = try tmp.dir.createFile("lock", .{ .read = true }); | |
| 687 | var file = try tmp.dir.createFile(io, "lock", .{ .read = true }); | |
| 688 | 688 | defer file.close(io); |
| 689 | 689 | try file.setEndPos(2); |
| 690 | 690 | const fd = file.handle; |
| ... | ... | @@ -881,7 +881,7 @@ test "isatty" { |
| 881 | 881 | var tmp = tmpDir(.{}); |
| 882 | 882 | defer tmp.cleanup(); |
| 883 | 883 | |
| 884 | var file = try tmp.dir.createFile("foo", .{}); | |
| 884 | var file = try tmp.dir.createFile(io, "foo", .{}); | |
| 885 | 885 | defer file.close(io); |
| 886 | 886 | |
| 887 | 887 | try expectEqual(posix.isatty(file.handle), false); |
| ... | ... | @@ -893,7 +893,7 @@ test "pread with empty buffer" { |
| 893 | 893 | var tmp = tmpDir(.{}); |
| 894 | 894 | defer tmp.cleanup(); |
| 895 | 895 | |
| 896 | var file = try tmp.dir.createFile("pread_empty", .{ .read = true }); | |
| 896 | var file = try tmp.dir.createFile(io, "pread_empty", .{ .read = true }); | |
| 897 | 897 | defer file.close(io); |
| 898 | 898 | |
| 899 | 899 | const bytes = try a.alloc(u8, 0); |
| ... | ... | @@ -909,7 +909,7 @@ test "write with empty buffer" { |
| 909 | 909 | var tmp = tmpDir(.{}); |
| 910 | 910 | defer tmp.cleanup(); |
| 911 | 911 | |
| 912 | var file = try tmp.dir.createFile("write_empty", .{}); | |
| 912 | var file = try tmp.dir.createFile(io, "write_empty", .{}); | |
| 913 | 913 | defer file.close(io); |
| 914 | 914 | |
| 915 | 915 | const bytes = try a.alloc(u8, 0); |
| ... | ... | @@ -925,7 +925,7 @@ test "pwrite with empty buffer" { |
| 925 | 925 | var tmp = tmpDir(.{}); |
| 926 | 926 | defer tmp.cleanup(); |
| 927 | 927 | |
| 928 | var file = try tmp.dir.createFile("pwrite_empty", .{}); | |
| 928 | var file = try tmp.dir.createFile(io, "pwrite_empty", .{}); | |
| 929 | 929 | defer file.close(io); |
| 930 | 930 | |
| 931 | 931 | const bytes = try a.alloc(u8, 0); |
| ... | ... | @@ -965,35 +965,35 @@ test "fchmodat smoke test" { |
| 965 | 965 | var tmp = tmpDir(.{}); |
| 966 | 966 | defer tmp.cleanup(); |
| 967 | 967 | |
| 968 | try expectError(error.FileNotFound, posix.fchmodat(tmp.dir.fd, "regfile", 0o666, 0)); | |
| 968 | try expectError(error.FileNotFound, posix.fchmodat(tmp.dir.handle, "regfile", 0o666, 0)); | |
| 969 | 969 | const fd = try posix.openat( |
| 970 | tmp.dir.fd, | |
| 970 | tmp.dir.handle, | |
| 971 | 971 | "regfile", |
| 972 | 972 | .{ .ACCMODE = .WRONLY, .CREAT = true, .EXCL = true, .TRUNC = true }, |
| 973 | 973 | 0o644, |
| 974 | 974 | ); |
| 975 | 975 | posix.close(fd); |
| 976 | 976 | |
| 977 | try posix.symlinkat("regfile", tmp.dir.fd, "symlink"); | |
| 978 | const sym_mode = try getFileMode(tmp.dir.fd, "symlink"); | |
| 977 | try posix.symlinkat("regfile", tmp.dir.handle, "symlink"); | |
| 978 | const sym_mode = try getFileMode(tmp.dir.handle, "symlink"); | |
| 979 | 979 | |
| 980 | try posix.fchmodat(tmp.dir.fd, "regfile", 0o640, 0); | |
| 981 | try expectMode(tmp.dir.fd, "regfile", 0o640); | |
| 982 | try posix.fchmodat(tmp.dir.fd, "regfile", 0o600, posix.AT.SYMLINK_NOFOLLOW); | |
| 983 | try expectMode(tmp.dir.fd, "regfile", 0o600); | |
| 980 | try posix.fchmodat(tmp.dir.handle, "regfile", 0o640, 0); | |
| 981 | try expectMode(tmp.dir.handle, "regfile", 0o640); | |
| 982 | try posix.fchmodat(tmp.dir.handle, "regfile", 0o600, posix.AT.SYMLINK_NOFOLLOW); | |
| 983 | try expectMode(tmp.dir.handle, "regfile", 0o600); | |
| 984 | 984 | |
| 985 | try posix.fchmodat(tmp.dir.fd, "symlink", 0o640, 0); | |
| 986 | try expectMode(tmp.dir.fd, "regfile", 0o640); | |
| 987 | try expectMode(tmp.dir.fd, "symlink", sym_mode); | |
| 985 | try posix.fchmodat(tmp.dir.handle, "symlink", 0o640, 0); | |
| 986 | try expectMode(tmp.dir.handle, "regfile", 0o640); | |
| 987 | try expectMode(tmp.dir.handle, "symlink", sym_mode); | |
| 988 | 988 | |
| 989 | 989 | var test_link = true; |
| 990 | posix.fchmodat(tmp.dir.fd, "symlink", 0o600, posix.AT.SYMLINK_NOFOLLOW) catch |err| switch (err) { | |
| 990 | posix.fchmodat(tmp.dir.handle, "symlink", 0o600, posix.AT.SYMLINK_NOFOLLOW) catch |err| switch (err) { | |
| 991 | 991 | error.OperationNotSupported => test_link = false, |
| 992 | 992 | else => |e| return e, |
| 993 | 993 | }; |
| 994 | 994 | if (test_link) |
| 995 | try expectMode(tmp.dir.fd, "symlink", 0o600); | |
| 996 | try expectMode(tmp.dir.fd, "regfile", 0o640); | |
| 995 | try expectMode(tmp.dir.handle, "symlink", 0o600); | |
| 996 | try expectMode(tmp.dir.handle, "regfile", 0o640); | |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | const CommonOpenFlags = packed struct { |
lib/std/process/Child.zig+1-1| ... | ... | @@ -677,7 +677,7 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { |
| 677 | 677 | setUpChildIo(self.stderr_behavior, stderr_pipe[1], posix.STDERR_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 678 | 678 | |
| 679 | 679 | if (self.cwd_dir) |cwd| { |
| 680 | posix.fchdir(cwd.fd) catch |err| forkChildErrReport(err_pipe[1], err); | |
| 680 | posix.fchdir(cwd.handle) catch |err| forkChildErrReport(err_pipe[1], err); | |
| 681 | 681 | } else if (self.cwd) |cwd| { |
| 682 | 682 | posix.chdir(cwd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 683 | 683 | } |
lib/std/std.zig+1-1| ... | ... | @@ -114,7 +114,7 @@ pub const options: Options = if (@hasDecl(root, "std_options")) root.std_options |
| 114 | 114 | pub const Options = struct { |
| 115 | 115 | enable_segfault_handler: bool = debug.default_enable_segfault_handler, |
| 116 | 116 | |
| 117 | /// Function used to implement `std.fs.cwd` for WASI. | |
| 117 | /// Function used to implement `std.Io.Dir.cwd` for WASI. | |
| 118 | 118 | wasiCwd: fn () os.wasi.fd_t = os.defaultWasiCwd, |
| 119 | 119 | |
| 120 | 120 | /// The current log level. |
lib/std/tar.zig+7-7| ... | ... | @@ -610,7 +610,7 @@ pub fn pipeToFileSystem(io: Io, dir: Io.Dir, reader: *Io.Reader, options: PipeOp |
| 610 | 610 | } |
| 611 | 611 | }, |
| 612 | 612 | .file => { |
| 613 | if (createDirAndFile(dir, file_name, fileMode(file.mode, options))) |fs_file| { | |
| 613 | if (createDirAndFile(io, dir, file_name, fileMode(file.mode, options))) |fs_file| { | |
| 614 | 614 | defer fs_file.close(io); |
| 615 | 615 | var file_writer = fs_file.writer(&file_contents_buffer); |
| 616 | 616 | try it.streamRemaining(file, &file_writer.interface); |
| ... | ... | @@ -638,12 +638,12 @@ pub fn pipeToFileSystem(io: Io, dir: Io.Dir, reader: *Io.Reader, options: PipeOp |
| 638 | 638 | } |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | fn createDirAndFile(dir: Io.Dir, file_name: []const u8, mode: Io.File.Mode) !Io.File { | |
| 642 | const fs_file = dir.createFile(file_name, .{ .exclusive = true, .mode = mode }) catch |err| { | |
| 641 | fn createDirAndFile(io: Io, dir: Io.Dir, file_name: []const u8, mode: Io.File.Mode) !Io.File { | |
| 642 | const fs_file = dir.createFile(io, file_name, .{ .exclusive = true, .mode = mode }) catch |err| { | |
| 643 | 643 | if (err == error.FileNotFound) { |
| 644 | 644 | if (std.fs.path.dirname(file_name)) |dir_name| { |
| 645 | 645 | try dir.makePath(dir_name); |
| 646 | return try dir.createFile(file_name, .{ .exclusive = true, .mode = mode }); | |
| 646 | return try dir.createFile(io, file_name, .{ .exclusive = true, .mode = mode }); | |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | return err; |
| ... | ... | @@ -880,9 +880,9 @@ test "create file and symlink" { |
| 880 | 880 | var root = testing.tmpDir(.{}); |
| 881 | 881 | defer root.cleanup(); |
| 882 | 882 | |
| 883 | var file = try createDirAndFile(root.dir, "file1", default_mode); | |
| 883 | var file = try createDirAndFile(io, root.dir, "file1", default_mode); | |
| 884 | 884 | file.close(io); |
| 885 | file = try createDirAndFile(root.dir, "a/b/c/file2", default_mode); | |
| 885 | file = try createDirAndFile(io, root.dir, "a/b/c/file2", default_mode); | |
| 886 | 886 | file.close(io); |
| 887 | 887 | |
| 888 | 888 | createDirAndSymlink(root.dir, "a/b/c/file2", "symlink1") catch |err| { |
| ... | ... | @@ -894,7 +894,7 @@ test "create file and symlink" { |
| 894 | 894 | |
| 895 | 895 | // Danglink symlnik, file created later |
| 896 | 896 | try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3"); |
| 897 | file = try createDirAndFile(root.dir, "g/h/i/file4", default_mode); | |
| 897 | file = try createDirAndFile(io, root.dir, "g/h/i/file4", default_mode); | |
| 898 | 898 | file.close(io); |
| 899 | 899 | } |
| 900 | 900 |
lib/std/testing.zig+1-1| ... | ... | @@ -628,7 +628,7 @@ pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir { |
| 628 | 628 | var sub_path: [TmpDir.sub_path_len]u8 = undefined; |
| 629 | 629 | _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes); |
| 630 | 630 | |
| 631 | const cwd = std.fs.cwd(); | |
| 631 | const cwd = Io.Dir.cwd(); | |
| 632 | 632 | var cache_dir = cwd.makeOpenPath(".zig-cache", .{}) catch |
| 633 | 633 | @panic("unable to make tmp dir for testing: unable to make and open .zig-cache dir"); |
| 634 | 634 | defer cache_dir.close(io); |
lib/std/zig/LibCInstallation.zig+6-6| ... | ... | @@ -57,7 +57,7 @@ pub fn parse( |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | const contents = try std.fs.cwd().readFileAlloc(libc_file, allocator, .limited(std.math.maxInt(usize))); | |
| 60 | const contents = try Io.Dir.cwd().readFileAlloc(libc_file, allocator, .limited(std.math.maxInt(usize))); | |
| 61 | 61 | defer allocator.free(contents); |
| 62 | 62 | |
| 63 | 63 | var it = std.mem.tokenizeScalar(u8, contents, '\n'); |
| ... | ... | @@ -337,7 +337,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, args: FindNativeOptions) F |
| 337 | 337 | // search in reverse order |
| 338 | 338 | const search_path_untrimmed = search_paths.items[search_paths.items.len - path_i - 1]; |
| 339 | 339 | const search_path = std.mem.trimStart(u8, search_path_untrimmed, " "); |
| 340 | var search_dir = fs.cwd().openDir(search_path, .{}) catch |err| switch (err) { | |
| 340 | var search_dir = Io.Dir.cwd().openDir(search_path, .{}) catch |err| switch (err) { | |
| 341 | 341 | error.FileNotFound, |
| 342 | 342 | error.NotDir, |
| 343 | 343 | error.NoDevice, |
| ... | ... | @@ -392,7 +392,7 @@ fn findNativeIncludeDirWindows( |
| 392 | 392 | result_buf.shrinkAndFree(0); |
| 393 | 393 | try result_buf.print("{s}\\Include\\{s}\\ucrt", .{ install.path, install.version }); |
| 394 | 394 | |
| 395 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | |
| 395 | var dir = Io.Dir.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | |
| 396 | 396 | error.FileNotFound, |
| 397 | 397 | error.NotDir, |
| 398 | 398 | error.NoDevice, |
| ... | ... | @@ -440,7 +440,7 @@ fn findNativeCrtDirWindows( |
| 440 | 440 | result_buf.shrinkAndFree(0); |
| 441 | 441 | try result_buf.print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ install.path, install.version, arch_sub_dir }); |
| 442 | 442 | |
| 443 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | |
| 443 | var dir = Io.Dir.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | |
| 444 | 444 | error.FileNotFound, |
| 445 | 445 | error.NotDir, |
| 446 | 446 | error.NoDevice, |
| ... | ... | @@ -508,7 +508,7 @@ fn findNativeKernel32LibDir( |
| 508 | 508 | result_buf.shrinkAndFree(0); |
| 509 | 509 | try result_buf.print("{s}\\Lib\\{s}\\um\\{s}", .{ install.path, install.version, arch_sub_dir }); |
| 510 | 510 | |
| 511 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | |
| 511 | var dir = Io.Dir.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | |
| 512 | 512 | error.FileNotFound, |
| 513 | 513 | error.NotDir, |
| 514 | 514 | error.NoDevice, |
| ... | ... | @@ -544,7 +544,7 @@ fn findNativeMsvcIncludeDir( |
| 544 | 544 | const dir_path = try fs.path.join(allocator, &[_][]const u8{ up2, "include" }); |
| 545 | 545 | errdefer allocator.free(dir_path); |
| 546 | 546 | |
| 547 | var dir = fs.cwd().openDir(dir_path, .{}) catch |err| switch (err) { | |
| 547 | var dir = Io.Dir.cwd().openDir(dir_path, .{}) catch |err| switch (err) { | |
| 548 | 548 | error.FileNotFound, |
| 549 | 549 | error.NotDir, |
| 550 | 550 | error.NoDevice, |
lib/std/zig/WindowsSdk.zig+1-1| ... | ... | @@ -828,7 +828,7 @@ const MsvcLibDir = struct { |
| 828 | 828 | |
| 829 | 829 | try lib_dir_buf.appendSlice("VC\\Auxiliary\\Build\\Microsoft.VCToolsVersion.default.txt"); |
| 830 | 830 | var default_tools_version_buf: [512]u8 = undefined; |
| 831 | const default_tools_version_contents = std.fs.cwd().readFile(lib_dir_buf.items, &default_tools_version_buf) catch { | |
| 831 | const default_tools_version_contents = Io.Dir.cwd().readFile(lib_dir_buf.items, &default_tools_version_buf) catch { | |
| 832 | 832 | return error.PathNotFound; |
| 833 | 833 | }; |
| 834 | 834 | var tokenizer = std.mem.tokenizeAny(u8, default_tools_version_contents, " \r\n"); |
lib/std/zig/system.zig+4-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | const native_endian = builtin.cpu.arch.endian(); | |
| 3 | ||
| 2 | 4 | const std = @import("../std.zig"); |
| 3 | 5 | const mem = std.mem; |
| 4 | 6 | const elf = std.elf; |
| 5 | 7 | const fs = std.fs; |
| 6 | 8 | const assert = std.debug.assert; |
| 7 | 9 | const Target = std.Target; |
| 8 | const native_endian = builtin.cpu.arch.endian(); | |
| 9 | 10 | const posix = std.posix; |
| 10 | 11 | const Io = std.Io; |
| 11 | 12 | |
| ... | ... | @@ -69,7 +70,7 @@ pub fn getExternalExecutor( |
| 69 | 70 | if (os_match and cpu_ok) native: { |
| 70 | 71 | if (options.link_libc) { |
| 71 | 72 | if (candidate.dynamic_linker.get()) |candidate_dl| { |
| 72 | fs.cwd().access(candidate_dl, .{}) catch { | |
| 73 | Io.Dir.cwd().access(candidate_dl, .{}) catch { | |
| 73 | 74 | bad_result = .{ .bad_dl = candidate_dl }; |
| 74 | 75 | break :native; |
| 75 | 76 | }; |
| ... | ... | @@ -710,6 +711,7 @@ fn abiAndDynamicLinkerFromFile( |
| 710 | 711 | error.SystemResources, |
| 711 | 712 | error.FileSystem, |
| 712 | 713 | error.SymLinkLoop, |
| 714 | error.Canceled, | |
| 713 | 715 | error.Unexpected, |
| 714 | 716 | => |e| return e, |
| 715 | 717 | }; |
lib/std/zig/system/darwin/macos.zig+4-3| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | const std = @import("std"); | |
| 2 | 1 | const builtin = @import("builtin"); |
| 2 | ||
| 3 | const std = @import("std"); | |
| 4 | const Io = std.Io; | |
| 3 | 5 | const assert = std.debug.assert; |
| 4 | 6 | const mem = std.mem; |
| 5 | 7 | const testing = std.testing; |
| 6 | ||
| 7 | 8 | const Target = std.Target; |
| 8 | 9 | |
| 9 | 10 | /// Detect macOS version. |
| ... | ... | @@ -54,7 +55,7 @@ pub fn detect(target_os: *Target.Os) !void { |
| 54 | 55 | // approx. 4 times historical file size |
| 55 | 56 | var buf: [2048]u8 = undefined; |
| 56 | 57 | |
| 57 | if (std.fs.cwd().readFile(path, &buf)) |bytes| { | |
| 58 | if (Io.Dir.cwd().readFile(path, &buf)) |bytes| { | |
| 58 | 59 | if (parseSystemVersion(bytes)) |ver| { |
| 59 | 60 | // never return non-canonical `10.(16+)` |
| 60 | 61 | if (!(ver.major == 10 and ver.minor >= 16)) { |
lib/std/zip.zig+2-2| ... | ... | @@ -564,9 +564,9 @@ pub const Iterator = struct { |
| 564 | 564 | defer parent_dir.close(io); |
| 565 | 565 | |
| 566 | 566 | const basename = std.fs.path.basename(filename); |
| 567 | break :blk try parent_dir.createFile(basename, .{ .exclusive = true }); | |
| 567 | break :blk try parent_dir.createFile(io, basename, .{ .exclusive = true }); | |
| 568 | 568 | } |
| 569 | break :blk try dest.createFile(filename, .{ .exclusive = true }); | |
| 569 | break :blk try dest.createFile(io, filename, .{ .exclusive = true }); | |
| 570 | 570 | }; |
| 571 | 571 | defer out_file.close(io); |
| 572 | 572 | var out_file_buffer: [1024]u8 = undefined; |
src/Compilation.zig+10-10| ... | ... | @@ -450,7 +450,7 @@ pub const Path = struct { |
| 450 | 450 | const dir = switch (p.root) { |
| 451 | 451 | .none => { |
| 452 | 452 | const cwd_sub_path = absToCwdRelative(p.sub_path, dirs.cwd); |
| 453 | return .{ fs.cwd(), cwd_sub_path }; | |
| 453 | return .{ Io.Dir.cwd(), cwd_sub_path }; | |
| 454 | 454 | }, |
| 455 | 455 | .zig_lib => dirs.zig_lib.handle, |
| 456 | 456 | .global_cache => dirs.global_cache.handle, |
| ... | ... | @@ -723,7 +723,7 @@ pub const Directories = struct { |
| 723 | 723 | |
| 724 | 724 | pub fn deinit(dirs: *Directories, io: Io) void { |
| 725 | 725 | // The local and global caches could be the same. |
| 726 | const close_local = dirs.local_cache.handle.fd != dirs.global_cache.handle.fd; | |
| 726 | const close_local = dirs.local_cache.handle.handle != dirs.global_cache.handle.handle; | |
| 727 | 727 | |
| 728 | 728 | dirs.global_cache.handle.close(io); |
| 729 | 729 | if (close_local) dirs.local_cache.handle.close(io); |
| ... | ... | @@ -814,7 +814,7 @@ pub const Directories = struct { |
| 814 | 814 | return .{ |
| 815 | 815 | .path = if (std.mem.eql(u8, name, ".")) null else name, |
| 816 | 816 | .handle = .{ |
| 817 | .fd = preopens.find(name) orelse fatal("WASI preopen not found: '{s}'", .{name}), | |
| 817 | .handle = preopens.find(name) orelse fatal("WASI preopen not found: '{s}'", .{name}), | |
| 818 | 818 | }, |
| 819 | 819 | }; |
| 820 | 820 | } |
| ... | ... | @@ -824,8 +824,8 @@ pub const Directories = struct { |
| 824 | 824 | }; |
| 825 | 825 | const nonempty_path = if (path.len == 0) "." else path; |
| 826 | 826 | const handle_or_err = switch (thing) { |
| 827 | .@"zig lib" => fs.cwd().openDir(nonempty_path, .{}), | |
| 828 | .@"global cache", .@"local cache" => fs.cwd().makeOpenPath(nonempty_path, .{}), | |
| 827 | .@"zig lib" => Io.Dir.cwd().openDir(nonempty_path, .{}), | |
| 828 | .@"global cache", .@"local cache" => Io.Dir.cwd().makeOpenPath(nonempty_path, .{}), | |
| 829 | 829 | }; |
| 830 | 830 | return .{ |
| 831 | 831 | .path = if (path.len == 0) null else path, |
| ... | ... | @@ -1104,7 +1104,7 @@ pub const CObject = struct { |
| 1104 | 1104 | const source_line = source_line: { |
| 1105 | 1105 | if (diag.src_loc.offset == 0 or diag.src_loc.column == 0) break :source_line 0; |
| 1106 | 1106 | |
| 1107 | const file = fs.cwd().openFile(io, file_name, .{}) catch break :source_line 0; | |
| 1107 | const file = Io.Dir.cwd().openFile(io, file_name, .{}) catch break :source_line 0; | |
| 1108 | 1108 | defer file.close(io); |
| 1109 | 1109 | var buffer: [1024]u8 = undefined; |
| 1110 | 1110 | var file_reader = file.reader(io, &buffer); |
| ... | ... | @@ -1179,7 +1179,7 @@ pub const CObject = struct { |
| 1179 | 1179 | }; |
| 1180 | 1180 | |
| 1181 | 1181 | var buffer: [1024]u8 = undefined; |
| 1182 | const file = try fs.cwd().openFile(io, path, .{}); | |
| 1182 | const file = try Io.Dir.cwd().openFile(io, path, .{}); | |
| 1183 | 1183 | defer file.close(io); |
| 1184 | 1184 | var file_reader = file.reader(io, &buffer); |
| 1185 | 1185 | var bc = std.zig.llvm.BitcodeReader.init(gpa, .{ .reader = &file_reader.interface }); |
| ... | ... | @@ -2109,7 +2109,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2109 | 2109 | }, |
| 2110 | 2110 | }; |
| 2111 | 2111 | // These correspond to std.zig.Server.Message.PathPrefix. |
| 2112 | cache.addPrefix(.{ .path = null, .handle = fs.cwd() }); | |
| 2112 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); | |
| 2113 | 2113 | cache.addPrefix(options.dirs.zig_lib); |
| 2114 | 2114 | cache.addPrefix(options.dirs.local_cache); |
| 2115 | 2115 | cache.addPrefix(options.dirs.global_cache); |
| ... | ... | @@ -5220,7 +5220,7 @@ fn createDepFile( |
| 5220 | 5220 | binfile: Cache.Path, |
| 5221 | 5221 | ) anyerror!void { |
| 5222 | 5222 | var buf: [4096]u8 = undefined; |
| 5223 | var af = try std.fs.cwd().atomicFile(depfile, .{ .write_buffer = &buf }); | |
| 5223 | var af = try Io.Dir.cwd().atomicFile(depfile, .{ .write_buffer = &buf }); | |
| 5224 | 5224 | defer af.deinit(); |
| 5225 | 5225 | |
| 5226 | 5226 | comp.writeDepFile(binfile, &af.file_writer.interface) catch return af.file_writer.err.?; |
| ... | ... | @@ -5284,7 +5284,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 5284 | 5284 | }; |
| 5285 | 5285 | } |
| 5286 | 5286 | |
| 5287 | var tar_file = out_dir.createFile("sources.tar", .{}) catch |err| { | |
| 5287 | var tar_file = out_dir.createFile(io, "sources.tar", .{}) catch |err| { | |
| 5288 | 5288 | return comp.lockAndSetMiscFailure( |
| 5289 | 5289 | .docs_copy, |
| 5290 | 5290 | "unable to create '{f}/sources.tar': {s}", |
src/Package/Fetch.zig+6-6| ... | ... | @@ -383,14 +383,14 @@ pub fn run(f: *Fetch) RunError!void { |
| 383 | 383 | }, |
| 384 | 384 | .remote => |remote| remote, |
| 385 | 385 | .path_or_url => |path_or_url| { |
| 386 | if (fs.cwd().openDir(path_or_url, .{ .iterate = true })) |dir| { | |
| 386 | if (Io.Dir.cwd().openDir(path_or_url, .{ .iterate = true })) |dir| { | |
| 387 | 387 | var resource: Resource = .{ .dir = dir }; |
| 388 | 388 | return f.runResource(path_or_url, &resource, null); |
| 389 | 389 | } else |dir_err| { |
| 390 | 390 | var server_header_buffer: [init_resource_buffer_size]u8 = undefined; |
| 391 | 391 | |
| 392 | 392 | const file_err = if (dir_err == error.NotDir) e: { |
| 393 | if (fs.cwd().openFile(io, path_or_url, .{})) |file| { | |
| 393 | if (Io.Dir.cwd().openFile(io, path_or_url, .{})) |file| { | |
| 394 | 394 | var resource: Resource = .{ .file = file.reader(io, &server_header_buffer) }; |
| 395 | 395 | return f.runResource(path_or_url, &resource, null); |
| 396 | 396 | } else |err| break :e err; |
| ... | ... | @@ -1303,7 +1303,7 @@ fn unzip( |
| 1303 | 1303 | const random_integer = std.crypto.random.int(u64); |
| 1304 | 1304 | zip_path[prefix.len..][0..random_len].* = std.fmt.hex(random_integer); |
| 1305 | 1305 | |
| 1306 | break cache_root.handle.createFile(&zip_path, .{ | |
| 1306 | break cache_root.handle.createFile(io, &zip_path, .{ | |
| 1307 | 1307 | .exclusive = true, |
| 1308 | 1308 | .read = true, |
| 1309 | 1309 | }) catch |err| switch (err) { |
| ... | ... | @@ -1365,7 +1365,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U |
| 1365 | 1365 | { |
| 1366 | 1366 | var pack_dir = try out_dir.makeOpenPath(".git", .{}); |
| 1367 | 1367 | defer pack_dir.close(io); |
| 1368 | var pack_file = try pack_dir.createFile("pkg.pack", .{ .read = true }); | |
| 1368 | var pack_file = try pack_dir.createFile(io, "pkg.pack", .{ .read = true }); | |
| 1369 | 1369 | defer pack_file.close(io); |
| 1370 | 1370 | var pack_file_buffer: [4096]u8 = undefined; |
| 1371 | 1371 | var pack_file_reader = b: { |
| ... | ... | @@ -1376,7 +1376,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U |
| 1376 | 1376 | break :b pack_file_writer.moveToReader(io); |
| 1377 | 1377 | }; |
| 1378 | 1378 | |
| 1379 | var index_file = try pack_dir.createFile("pkg.idx", .{ .read = true }); | |
| 1379 | var index_file = try pack_dir.createFile(io, "pkg.idx", .{ .read = true }); | |
| 1380 | 1380 | defer index_file.close(io); |
| 1381 | 1381 | var index_file_buffer: [2000]u8 = undefined; |
| 1382 | 1382 | var index_file_writer = index_file.writer(&index_file_buffer); |
| ... | ... | @@ -2235,7 +2235,7 @@ test "set executable bit based on file content" { |
| 2235 | 2235 | fn saveEmbedFile(io: Io, comptime tarball_name: []const u8, dir: Io.Dir) !void { |
| 2236 | 2236 | //const tarball_name = "duplicate_paths_excluded.tar.gz"; |
| 2237 | 2237 | const tarball_content = @embedFile("Fetch/testdata/" ++ tarball_name); |
| 2238 | var tmp_file = try dir.createFile(tarball_name, .{}); | |
| 2238 | var tmp_file = try dir.createFile(io, tarball_name, .{}); | |
| 2239 | 2239 | defer tmp_file.close(io); |
| 2240 | 2240 | try tmp_file.writeAll(tarball_content); |
| 2241 | 2241 | } |
src/Package/Fetch/git.zig+6-6| ... | ... | @@ -264,7 +264,7 @@ pub const Repository = struct { |
| 264 | 264 | try repository.odb.seekOid(entry.oid); |
| 265 | 265 | const file_object = try repository.odb.readObject(); |
| 266 | 266 | if (file_object.type != .blob) return error.InvalidFile; |
| 267 | var file = dir.createFile(entry.name, .{ .exclusive = true }) catch |e| { | |
| 267 | var file = dir.createFile(io, entry.name, .{ .exclusive = true }) catch |e| { | |
| 268 | 268 | const file_name = try std.fs.path.join(diagnostics.allocator, &.{ current_path, entry.name }); |
| 269 | 269 | errdefer diagnostics.allocator.free(file_name); |
| 270 | 270 | try diagnostics.errors.append(diagnostics.allocator, .{ .unable_to_create_file = .{ |
| ... | ... | @@ -1584,14 +1584,14 @@ fn runRepositoryTest(io: Io, comptime format: Oid.Format, head_commit: []const u |
| 1584 | 1584 | |
| 1585 | 1585 | var git_dir = testing.tmpDir(.{}); |
| 1586 | 1586 | defer git_dir.cleanup(); |
| 1587 | var pack_file = try git_dir.dir.createFile("testrepo.pack", .{ .read = true }); | |
| 1587 | var pack_file = try git_dir.dir.createFile(io, "testrepo.pack", .{ .read = true }); | |
| 1588 | 1588 | defer pack_file.close(io); |
| 1589 | 1589 | try pack_file.writeAll(testrepo_pack); |
| 1590 | 1590 | |
| 1591 | 1591 | var pack_file_buffer: [2000]u8 = undefined; |
| 1592 | 1592 | var pack_file_reader = pack_file.reader(io, &pack_file_buffer); |
| 1593 | 1593 | |
| 1594 | var index_file = try git_dir.dir.createFile("testrepo.idx", .{ .read = true }); | |
| 1594 | var index_file = try git_dir.dir.createFile(io, "testrepo.idx", .{ .read = true }); | |
| 1595 | 1595 | defer index_file.close(io); |
| 1596 | 1596 | var index_file_buffer: [2000]u8 = undefined; |
| 1597 | 1597 | var index_file_writer = index_file.writer(&index_file_buffer); |
| ... | ... | @@ -1714,20 +1714,20 @@ pub fn main() !void { |
| 1714 | 1714 | |
| 1715 | 1715 | const format = std.meta.stringToEnum(Oid.Format, args[1]) orelse return error.InvalidFormat; |
| 1716 | 1716 | |
| 1717 | var pack_file = try std.fs.cwd().openFile(io, args[2], .{}); | |
| 1717 | var pack_file = try Io.Dir.cwd().openFile(io, args[2], .{}); | |
| 1718 | 1718 | defer pack_file.close(io); |
| 1719 | 1719 | var pack_file_buffer: [4096]u8 = undefined; |
| 1720 | 1720 | var pack_file_reader = pack_file.reader(io, &pack_file_buffer); |
| 1721 | 1721 | |
| 1722 | 1722 | const commit = try Oid.parse(format, args[3]); |
| 1723 | var worktree = try std.fs.cwd().makeOpenPath(args[4], .{}); | |
| 1723 | var worktree = try Io.Dir.cwd().makeOpenPath(args[4], .{}); | |
| 1724 | 1724 | defer worktree.close(io); |
| 1725 | 1725 | |
| 1726 | 1726 | var git_dir = try worktree.makeOpenPath(".git", .{}); |
| 1727 | 1727 | defer git_dir.close(io); |
| 1728 | 1728 | |
| 1729 | 1729 | std.debug.print("Starting index...\n", .{}); |
| 1730 | var index_file = try git_dir.createFile("idx", .{ .read = true }); | |
| 1730 | var index_file = try git_dir.createFile(io, "idx", .{ .read = true }); | |
| 1731 | 1731 | defer index_file.close(io); |
| 1732 | 1732 | var index_file_buffer: [4096]u8 = undefined; |
| 1733 | 1733 | var index_file_writer = index_file.writer(&index_file_buffer); |
src/Zcu/PerThread.zig+2-2| ... | ... | @@ -170,7 +170,7 @@ pub fn updateFile( |
| 170 | 170 | // version. Likewise if we're working on AstGen and another process asks for |
| 171 | 171 | // the cached file, they'll get it. |
| 172 | 172 | const cache_file = while (true) { |
| 173 | break zir_dir.createFile(&hex_digest, .{ | |
| 173 | break zir_dir.createFile(io, &hex_digest, .{ | |
| 174 | 174 | .read = true, |
| 175 | 175 | .truncate = false, |
| 176 | 176 | .lock = lock, |
| ... | ... | @@ -196,7 +196,7 @@ pub fn updateFile( |
| 196 | 196 | cache_directory, |
| 197 | 197 | }); |
| 198 | 198 | } |
| 199 | break zir_dir.createFile(&hex_digest, .{ | |
| 199 | break zir_dir.createFile(io, &hex_digest, .{ | |
| 200 | 200 | .read = true, |
| 201 | 201 | .truncate = false, |
| 202 | 202 | .lock = lock, |
src/codegen/llvm.zig+10-7| ... | ... | @@ -1,19 +1,22 @@ |
| 1 | const std = @import("std"); | |
| 2 | 1 | const builtin = @import("builtin"); |
| 2 | ||
| 3 | const std = @import("std"); | |
| 4 | const Io = std.Io; | |
| 3 | 5 | const assert = std.debug.assert; |
| 4 | 6 | const Allocator = std.mem.Allocator; |
| 5 | 7 | const log = std.log.scoped(.codegen); |
| 6 | 8 | const math = std.math; |
| 7 | 9 | const DW = std.dwarf; |
| 8 | ||
| 9 | 10 | const Builder = std.zig.llvm.Builder; |
| 11 | ||
| 12 | const build_options = @import("build_options"); | |
| 10 | 13 | const llvm = if (build_options.have_llvm) |
| 11 | 14 | @import("llvm/bindings.zig") |
| 12 | 15 | else |
| 13 | 16 | @compileError("LLVM unavailable"); |
| 17 | ||
| 14 | 18 | const link = @import("../link.zig"); |
| 15 | 19 | const Compilation = @import("../Compilation.zig"); |
| 16 | const build_options = @import("build_options"); | |
| 17 | 20 | const Zcu = @import("../Zcu.zig"); |
| 18 | 21 | const InternPool = @import("../InternPool.zig"); |
| 19 | 22 | const Package = @import("../Package.zig"); |
| ... | ... | @@ -964,7 +967,7 @@ pub const Object = struct { |
| 964 | 967 | if (std.mem.eql(u8, path, "-")) { |
| 965 | 968 | o.builder.dump(); |
| 966 | 969 | } else { |
| 967 | o.builder.printToFilePath(std.fs.cwd(), path) catch |err| { | |
| 970 | o.builder.printToFilePath(Io.Dir.cwd(), path) catch |err| { | |
| 968 | 971 | log.err("failed printing LLVM module to \"{s}\": {s}", .{ path, @errorName(err) }); |
| 969 | 972 | }; |
| 970 | 973 | } |
| ... | ... | @@ -978,7 +981,7 @@ pub const Object = struct { |
| 978 | 981 | o.builder.clearAndFree(); |
| 979 | 982 | |
| 980 | 983 | if (options.pre_bc_path) |path| { |
| 981 | var file = std.fs.cwd().createFile(path, .{}) catch |err| | |
| 984 | var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| | |
| 982 | 985 | return diags.fail("failed to create '{s}': {s}", .{ path, @errorName(err) }); |
| 983 | 986 | defer file.close(io); |
| 984 | 987 | |
| ... | ... | @@ -991,7 +994,7 @@ pub const Object = struct { |
| 991 | 994 | options.post_ir_path == null and options.post_bc_path == null) return; |
| 992 | 995 | |
| 993 | 996 | if (options.post_bc_path) |path| { |
| 994 | var file = std.fs.cwd().createFile(path, .{}) catch |err| | |
| 997 | var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| | |
| 995 | 998 | return diags.fail("failed to create '{s}': {s}", .{ path, @errorName(err) }); |
| 996 | 999 | defer file.close(io); |
| 997 | 1000 | |
| ... | ... | @@ -2711,7 +2714,7 @@ pub const Object = struct { |
| 2711 | 2714 | } |
| 2712 | 2715 | |
| 2713 | 2716 | fn allocTypeName(o: *Object, pt: Zcu.PerThread, ty: Type) Allocator.Error![:0]const u8 { |
| 2714 | var aw: std.Io.Writer.Allocating = .init(o.gpa); | |
| 2717 | var aw: Io.Writer.Allocating = .init(o.gpa); | |
| 2715 | 2718 | defer aw.deinit(); |
| 2716 | 2719 | ty.print(&aw.writer, pt, null) catch |err| switch (err) { |
| 2717 | 2720 | error.WriteFailed => return error.OutOfMemory, |
src/fmt.zig+3-3| ... | ... | @@ -182,11 +182,11 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 182 | 182 | // Mark any excluded files/directories as already seen, |
| 183 | 183 | // so that they are skipped later during actual processing |
| 184 | 184 | for (excluded_files.items) |file_path| { |
| 185 | const stat = fs.cwd().statFile(file_path) catch |err| switch (err) { | |
| 185 | const stat = Io.Dir.cwd().statFile(file_path) catch |err| switch (err) { | |
| 186 | 186 | error.FileNotFound => continue, |
| 187 | 187 | // On Windows, statFile does not work for directories |
| 188 | 188 | error.IsDir => dir: { |
| 189 | var dir = try fs.cwd().openDir(file_path, .{}); | |
| 189 | var dir = try Io.Dir.cwd().openDir(file_path, .{}); | |
| 190 | 190 | defer dir.close(io); |
| 191 | 191 | break :dir try dir.stat(); |
| 192 | 192 | }, |
| ... | ... | @@ -196,7 +196,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | for (input_files.items) |file_path| { |
| 199 | try fmtPath(&fmt, file_path, check_flag, fs.cwd(), file_path); | |
| 199 | try fmtPath(&fmt, file_path, check_flag, Io.Dir.cwd(), file_path); | |
| 200 | 200 | } |
| 201 | 201 | try fmt.stdout_writer.interface.flush(); |
| 202 | 202 | if (fmt.any_error) { |
src/introspect.zig+2-2| ... | ... | @@ -82,7 +82,7 @@ pub fn findZigLibDirFromSelfExe( |
| 82 | 82 | cwd_path: []const u8, |
| 83 | 83 | self_exe_path: []const u8, |
| 84 | 84 | ) error{ OutOfMemory, FileNotFound }!Cache.Directory { |
| 85 | const cwd = fs.cwd(); | |
| 85 | const cwd = Io.Dir.cwd(); | |
| 86 | 86 | var cur_path: []const u8 = self_exe_path; |
| 87 | 87 | while (fs.path.dirname(cur_path)) |dirname| : (cur_path = dirname) { |
| 88 | 88 | var base_dir = cwd.openDir(dirname, .{}) catch continue; |
| ... | ... | @@ -206,7 +206,7 @@ pub fn resolveSuitableLocalCacheDir(arena: Allocator, cwd: []const u8) Allocator |
| 206 | 206 | var cur_dir = cwd; |
| 207 | 207 | while (true) { |
| 208 | 208 | const joined = try fs.path.join(arena, &.{ cur_dir, Package.build_zig_basename }); |
| 209 | if (fs.cwd().access(joined, .{})) |_| { | |
| 209 | if (Io.Dir.cwd().access(joined, .{})) |_| { | |
| 210 | 210 | return try fs.path.join(arena, &.{ cur_dir, default_local_zig_cache_basename }); |
| 211 | 211 | } else |err| switch (err) { |
| 212 | 212 | error.FileNotFound => { |
src/libs/freebsd.zig+6-6| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const Allocator = std.mem.Allocator; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const log = std.log; |
| 5 | const fs = std.fs; | |
| 6 | const path = fs.path; | |
| 6 | const path = std.Io.Dir.path; | |
| 7 | 7 | const assert = std.debug.assert; |
| 8 | 8 | const Version = std.SemanticVersion; |
| 9 | 9 | const Path = std.Build.Cache.Path; |
| ... | ... | @@ -446,7 +446,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 446 | 446 | .io = io, |
| 447 | 447 | .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath("h", .{}), |
| 448 | 448 | }; |
| 449 | cache.addPrefix(.{ .path = null, .handle = fs.cwd() }); | |
| 449 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); | |
| 450 | 450 | cache.addPrefix(comp.dirs.zig_lib); |
| 451 | 451 | cache.addPrefix(comp.dirs.global_cache); |
| 452 | 452 | defer cache.manifest_dir.close(io); |
| ... | ... | @@ -468,7 +468,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 468 | 468 | .lock = man.toOwnedLock(), |
| 469 | 469 | .dir_path = .{ |
| 470 | 470 | .root_dir = comp.dirs.global_cache, |
| 471 | .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), | |
| 471 | .sub_path = try gpa.dupe(u8, "o" ++ path.sep_str ++ digest), | |
| 472 | 472 | }, |
| 473 | 473 | }); |
| 474 | 474 | } |
| ... | ... | @@ -986,7 +986,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 986 | 986 | .lock = man.toOwnedLock(), |
| 987 | 987 | .dir_path = .{ |
| 988 | 988 | .root_dir = comp.dirs.global_cache, |
| 989 | .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), | |
| 989 | .sub_path = try gpa.dupe(u8, "o" ++ path.sep_str ++ digest), | |
| 990 | 990 | }, |
| 991 | 991 | }); |
| 992 | 992 | } |
| ... | ... | @@ -1014,7 +1014,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) std.Io.C |
| 1014 | 1014 | const so_path: Path = .{ |
| 1015 | 1015 | .root_dir = so_files.dir_path.root_dir, |
| 1016 | 1016 | .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{ |
| 1017 | so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.getSoVersion(&target.os), | |
| 1017 | so_files.dir_path.sub_path, path.sep, lib.name, lib.getSoVersion(&target.os), | |
| 1018 | 1018 | }) catch return comp.setAllocFailure(), |
| 1019 | 1019 | }; |
| 1020 | 1020 | task_buffer[task_buffer_i] = .{ .load_dso = so_path }; |
src/libs/glibc.zig+8-8| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const Allocator = std.mem.Allocator; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const log = std.log; |
| 5 | const fs = std.fs; | |
| 6 | const path = fs.path; | |
| 6 | const path = std.Io.Dir.path; | |
| 7 | 7 | const assert = std.debug.assert; |
| 8 | 8 | const Version = std.SemanticVersion; |
| 9 | 9 | const Path = std.Build.Cache.Path; |
| ... | ... | @@ -681,7 +681,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 681 | 681 | .io = io, |
| 682 | 682 | .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath("h", .{}), |
| 683 | 683 | }; |
| 684 | cache.addPrefix(.{ .path = null, .handle = fs.cwd() }); | |
| 684 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); | |
| 685 | 685 | cache.addPrefix(comp.dirs.zig_lib); |
| 686 | 686 | cache.addPrefix(comp.dirs.global_cache); |
| 687 | 687 | defer cache.manifest_dir.close(io); |
| ... | ... | @@ -703,7 +703,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 703 | 703 | .lock = man.toOwnedLock(), |
| 704 | 704 | .dir_path = .{ |
| 705 | 705 | .root_dir = comp.dirs.global_cache, |
| 706 | .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), | |
| 706 | .sub_path = try gpa.dupe(u8, "o" ++ path.sep_str ++ digest), | |
| 707 | 707 | }, |
| 708 | 708 | }); |
| 709 | 709 | } |
| ... | ... | @@ -775,7 +775,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 775 | 775 | try stubs_asm.appendSlice(".text\n"); |
| 776 | 776 | |
| 777 | 777 | var sym_i: usize = 0; |
| 778 | var sym_name_buf: std.Io.Writer.Allocating = .init(arena); | |
| 778 | var sym_name_buf: Io.Writer.Allocating = .init(arena); | |
| 779 | 779 | var opt_symbol_name: ?[]const u8 = null; |
| 780 | 780 | var versions_buffer: [32]u8 = undefined; |
| 781 | 781 | var versions_len: usize = undefined; |
| ... | ... | @@ -796,7 +796,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 796 | 796 | // twice, which causes a "duplicate symbol" assembler error. |
| 797 | 797 | var versions_written = std.AutoArrayHashMap(Version, void).init(arena); |
| 798 | 798 | |
| 799 | var inc_reader: std.Io.Reader = .fixed(metadata.inclusions); | |
| 799 | var inc_reader: Io.Reader = .fixed(metadata.inclusions); | |
| 800 | 800 | |
| 801 | 801 | const fn_inclusions_len = try inc_reader.takeInt(u16, .little); |
| 802 | 802 | |
| ... | ... | @@ -1130,7 +1130,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 1130 | 1130 | .lock = man.toOwnedLock(), |
| 1131 | 1131 | .dir_path = .{ |
| 1132 | 1132 | .root_dir = comp.dirs.global_cache, |
| 1133 | .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), | |
| 1133 | .sub_path = try gpa.dupe(u8, "o" ++ path.sep_str ++ digest), | |
| 1134 | 1134 | }, |
| 1135 | 1135 | }); |
| 1136 | 1136 | } |
| ... | ... | @@ -1156,7 +1156,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) std.Io.C |
| 1156 | 1156 | const so_path: Path = .{ |
| 1157 | 1157 | .root_dir = so_files.dir_path.root_dir, |
| 1158 | 1158 | .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{ |
| 1159 | so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover, | |
| 1159 | so_files.dir_path.sub_path, path.sep, lib.name, lib.sover, | |
| 1160 | 1160 | }) catch return comp.setAllocFailure(), |
| 1161 | 1161 | }; |
| 1162 | 1162 | task_buffer[task_buffer_i] = .{ .load_dso = so_path }; |
src/libs/mingw.zig+9-8| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const Allocator = std.mem.Allocator; |
| 3 | 4 | const mem = std.mem; |
| 4 | const path = std.fs.path; | |
| 5 | const path = std.Io.Dir.path; | |
| 5 | 6 | const assert = std.debug.assert; |
| 6 | 7 | const log = std.log.scoped(.mingw); |
| 7 | 8 | |
| ... | ... | @@ -259,7 +260,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 259 | 260 | .io = io, |
| 260 | 261 | .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath("h", .{}), |
| 261 | 262 | }; |
| 262 | cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); | |
| 263 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); | |
| 263 | 264 | cache.addPrefix(comp.dirs.zig_lib); |
| 264 | 265 | cache.addPrefix(comp.dirs.global_cache); |
| 265 | 266 | defer cache.manifest_dir.close(io); |
| ... | ... | @@ -304,7 +305,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 304 | 305 | .output = .{ .to_list = .{ .arena = .init(gpa) } }, |
| 305 | 306 | }; |
| 306 | 307 | defer diagnostics.deinit(); |
| 307 | var aro_comp = aro.Compilation.init(gpa, arena, io, &diagnostics, std.fs.cwd()); | |
| 308 | var aro_comp = aro.Compilation.init(gpa, arena, io, &diagnostics, Io.Dir.cwd()); | |
| 308 | 309 | defer aro_comp.deinit(); |
| 309 | 310 | |
| 310 | 311 | aro_comp.target = .fromZigTarget(target.*); |
| ... | ... | @@ -343,7 +344,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 343 | 344 | } |
| 344 | 345 | |
| 345 | 346 | const members = members: { |
| 346 | var aw: std.Io.Writer.Allocating = .init(gpa); | |
| 347 | var aw: Io.Writer.Allocating = .init(gpa); | |
| 347 | 348 | errdefer aw.deinit(); |
| 348 | 349 | try pp.prettyPrintTokens(&aw.writer, .result_only); |
| 349 | 350 | |
| ... | ... | @@ -376,7 +377,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 376 | 377 | errdefer gpa.free(lib_final_path); |
| 377 | 378 | |
| 378 | 379 | { |
| 379 | const lib_final_file = try o_dir.createFile(final_lib_basename, .{ .truncate = true }); | |
| 380 | const lib_final_file = try o_dir.createFile(io, final_lib_basename, .{ .truncate = true }); | |
| 380 | 381 | defer lib_final_file.close(io); |
| 381 | 382 | var buffer: [1024]u8 = undefined; |
| 382 | 383 | var file_writer = lib_final_file.writer(&buffer); |
| ... | ... | @@ -442,7 +443,7 @@ fn findDef( |
| 442 | 443 | } else { |
| 443 | 444 | try override_path.print(fmt_path, .{ lib_path, lib_name }); |
| 444 | 445 | } |
| 445 | if (std.fs.cwd().access(override_path.items, .{})) |_| { | |
| 446 | if (Io.Dir.cwd().access(override_path.items, .{})) |_| { | |
| 446 | 447 | return override_path.toOwnedSlice(); |
| 447 | 448 | } else |err| switch (err) { |
| 448 | 449 | error.FileNotFound => {}, |
| ... | ... | @@ -459,7 +460,7 @@ fn findDef( |
| 459 | 460 | } else { |
| 460 | 461 | try override_path.print(fmt_path, .{lib_name}); |
| 461 | 462 | } |
| 462 | if (std.fs.cwd().access(override_path.items, .{})) |_| { | |
| 463 | if (Io.Dir.cwd().access(override_path.items, .{})) |_| { | |
| 463 | 464 | return override_path.toOwnedSlice(); |
| 464 | 465 | } else |err| switch (err) { |
| 465 | 466 | error.FileNotFound => {}, |
| ... | ... | @@ -476,7 +477,7 @@ fn findDef( |
| 476 | 477 | } else { |
| 477 | 478 | try override_path.print(fmt_path, .{lib_name}); |
| 478 | 479 | } |
| 479 | if (std.fs.cwd().access(override_path.items, .{})) |_| { | |
| 480 | if (Io.Dir.cwd().access(override_path.items, .{})) |_| { | |
| 480 | 481 | return override_path.toOwnedSlice(); |
| 481 | 482 | } else |err| switch (err) { |
| 482 | 483 | error.FileNotFound => {}, |
src/libs/netbsd.zig+6-6| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const Io = std.Io; | |
| 2 | 3 | const Allocator = std.mem.Allocator; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | const log = std.log; |
| 5 | const fs = std.fs; | |
| 6 | const path = fs.path; | |
| 6 | const path = std.Io.Dir.path; | |
| 7 | 7 | const assert = std.debug.assert; |
| 8 | 8 | const Version = std.SemanticVersion; |
| 9 | 9 | const Path = std.Build.Cache.Path; |
| ... | ... | @@ -387,7 +387,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 387 | 387 | .io = io, |
| 388 | 388 | .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath("h", .{}), |
| 389 | 389 | }; |
| 390 | cache.addPrefix(.{ .path = null, .handle = fs.cwd() }); | |
| 390 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); | |
| 391 | 391 | cache.addPrefix(comp.dirs.zig_lib); |
| 392 | 392 | cache.addPrefix(comp.dirs.global_cache); |
| 393 | 393 | defer cache.manifest_dir.close(io); |
| ... | ... | @@ -409,7 +409,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 409 | 409 | .lock = man.toOwnedLock(), |
| 410 | 410 | .dir_path = .{ |
| 411 | 411 | .root_dir = comp.dirs.global_cache, |
| 412 | .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), | |
| 412 | .sub_path = try gpa.dupe(u8, "o" ++ path.sep_str ++ digest), | |
| 413 | 413 | }, |
| 414 | 414 | }); |
| 415 | 415 | } |
| ... | ... | @@ -640,7 +640,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 640 | 640 | .lock = man.toOwnedLock(), |
| 641 | 641 | .dir_path = .{ |
| 642 | 642 | .root_dir = comp.dirs.global_cache, |
| 643 | .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest), | |
| 643 | .sub_path = try gpa.dupe(u8, "o" ++ path.sep_str ++ digest), | |
| 644 | 644 | }, |
| 645 | 645 | }); |
| 646 | 646 | } |
| ... | ... | @@ -661,7 +661,7 @@ fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) std.Io.C |
| 661 | 661 | const so_path: Path = .{ |
| 662 | 662 | .root_dir = so_files.dir_path.root_dir, |
| 663 | 663 | .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{ |
| 664 | so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover, | |
| 664 | so_files.dir_path.sub_path, path.sep, lib.name, lib.sover, | |
| 665 | 665 | }) catch return comp.setAllocFailure(), |
| 666 | 666 | }; |
| 667 | 667 | task_buffer[task_buffer_i] = .{ .load_dso = so_path }; |
src/link/C.zig+2-2| ... | ... | @@ -136,7 +136,7 @@ pub fn createEmpty( |
| 136 | 136 | assert(!use_lld); |
| 137 | 137 | assert(!use_llvm); |
| 138 | 138 | |
| 139 | const file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 139 | const file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{ | |
| 140 | 140 | // Truncation is done on `flush`. |
| 141 | 141 | .truncate = false, |
| 142 | 142 | }); |
| ... | ... | @@ -792,7 +792,7 @@ pub fn flushEmitH(zcu: *Zcu) !void { |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | const directory = emit_h.loc.directory orelse zcu.comp.local_cache_directory; |
| 795 | const file = try directory.handle.createFile(emit_h.loc.basename, .{ | |
| 795 | const file = try directory.handle.createFile(io, emit_h.loc.basename, .{ | |
| 796 | 796 | // We set the end position explicitly below; by not truncating the file, we possibly |
| 797 | 797 | // make it easier on the file system by doing 1 reallocation instead of two. |
| 798 | 798 | .truncate = false, |
src/link/Coff.zig+4-2| ... | ... | @@ -631,12 +631,14 @@ fn create( |
| 631 | 631 | else => return error.UnsupportedCOFFArchitecture, |
| 632 | 632 | }; |
| 633 | 633 | |
| 634 | const io = comp.io; | |
| 635 | ||
| 634 | 636 | const coff = try arena.create(Coff); |
| 635 | const file = try path.root_dir.handle.createFile(comp.io, path.sub_path, .{ | |
| 637 | const file = try path.root_dir.handle.createFile(io, path.sub_path, .{ | |
| 636 | 638 | .read = true, |
| 637 | 639 | .mode = link.File.determineMode(comp.config.output_mode, comp.config.link_mode), |
| 638 | 640 | }); |
| 639 | errdefer file.close(comp.io); | |
| 641 | errdefer file.close(io); | |
| 640 | 642 | coff.* = .{ |
| 641 | 643 | .base = .{ |
| 642 | 644 | .tag = .coff2, |
src/link/Elf.zig+3-1| ... | ... | @@ -313,9 +313,11 @@ pub fn createEmpty( |
| 313 | 313 | const is_obj = output_mode == .Obj; |
| 314 | 314 | const is_obj_or_ar = is_obj or (output_mode == .Lib and link_mode == .static); |
| 315 | 315 | |
| 316 | const io = comp.io; | |
| 317 | ||
| 316 | 318 | // What path should this ELF linker code output to? |
| 317 | 319 | const sub_path = emit.sub_path; |
| 318 | self.base.file = try emit.root_dir.handle.createFile(sub_path, .{ | |
| 320 | self.base.file = try emit.root_dir.handle.createFile(io, sub_path, .{ | |
| 319 | 321 | .truncate = true, |
| 320 | 322 | .read = true, |
| 321 | 323 | .mode = link.File.determineMode(output_mode, link_mode), |
src/link/Lld.zig+2-2| ... | ... | @@ -1572,7 +1572,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1572 | 1572 | // report a nice error here with the file path if it fails instead of |
| 1573 | 1573 | // just returning the error code. |
| 1574 | 1574 | // chmod does not interact with umask, so we use a conservative -rwxr--r-- here. |
| 1575 | std.posix.fchmodat(fs.cwd().fd, full_out_path, 0o744, 0) catch |err| switch (err) { | |
| 1575 | std.posix.fchmodat(Io.Dir.cwd().handle, full_out_path, 0o744, 0) catch |err| switch (err) { | |
| 1576 | 1576 | error.OperationNotSupported => unreachable, // Not a symlink. |
| 1577 | 1577 | else => |e| return e, |
| 1578 | 1578 | }; |
| ... | ... | @@ -1624,7 +1624,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi |
| 1624 | 1624 | const rand_int = std.crypto.random.int(u64); |
| 1625 | 1625 | const rsp_path = "tmp" ++ s ++ std.fmt.hex(rand_int) ++ ".rsp"; |
| 1626 | 1626 | |
| 1627 | const rsp_file = try comp.dirs.local_cache.handle.createFile(rsp_path, .{}); | |
| 1627 | const rsp_file = try comp.dirs.local_cache.handle.createFile(io, rsp_path, .{}); | |
| 1628 | 1628 | defer comp.dirs.local_cache.handle.deleteFileZ(rsp_path) catch |err| |
| 1629 | 1629 | log.warn("failed to delete response file {s}: {s}", .{ rsp_path, @errorName(err) }); |
| 1630 | 1630 | { |
src/link/MachO.zig+8-6| ... | ... | @@ -219,7 +219,9 @@ pub fn createEmpty( |
| 219 | 219 | }; |
| 220 | 220 | errdefer self.base.destroy(); |
| 221 | 221 | |
| 222 | self.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 222 | const io = comp.io; | |
| 223 | ||
| 224 | self.base.file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{ | |
| 223 | 225 | .truncate = true, |
| 224 | 226 | .read = true, |
| 225 | 227 | .mode = link.File.determineMode(output_mode, link_mode), |
| ... | ... | @@ -1082,7 +1084,7 @@ fn accessLibPath( |
| 1082 | 1084 | test_path.clearRetainingCapacity(); |
| 1083 | 1085 | try test_path.print("{s}" ++ sep ++ "lib{s}{s}", .{ search_dir, name, ext }); |
| 1084 | 1086 | try checked_paths.append(try arena.dupe(u8, test_path.items)); |
| 1085 | fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 1087 | Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 1086 | 1088 | error.FileNotFound => continue, |
| 1087 | 1089 | else => |e| return e, |
| 1088 | 1090 | }; |
| ... | ... | @@ -1110,7 +1112,7 @@ fn accessFrameworkPath( |
| 1110 | 1112 | ext, |
| 1111 | 1113 | }); |
| 1112 | 1114 | try checked_paths.append(try arena.dupe(u8, test_path.items)); |
| 1113 | fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 1115 | Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 1114 | 1116 | error.FileNotFound => continue, |
| 1115 | 1117 | else => |e| return e, |
| 1116 | 1118 | }; |
| ... | ... | @@ -1191,7 +1193,7 @@ fn parseDependentDylibs(self: *MachO) !void { |
| 1191 | 1193 | try test_path.print("{s}{s}", .{ path, ext }); |
| 1192 | 1194 | } |
| 1193 | 1195 | try checked_paths.append(try arena.dupe(u8, test_path.items)); |
| 1194 | fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 1196 | Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 1195 | 1197 | error.FileNotFound => continue, |
| 1196 | 1198 | else => |e| return e, |
| 1197 | 1199 | }; |
| ... | ... | @@ -3289,7 +3291,7 @@ pub fn reopenDebugInfo(self: *MachO) !void { |
| 3289 | 3291 | var d_sym_bundle = try self.base.emit.root_dir.handle.makeOpenPath(d_sym_path, .{}); |
| 3290 | 3292 | defer d_sym_bundle.close(io); |
| 3291 | 3293 | |
| 3292 | self.d_sym.?.file = try d_sym_bundle.createFile(fs.path.basename(self.base.emit.sub_path), .{ | |
| 3294 | self.d_sym.?.file = try d_sym_bundle.createFile(io, fs.path.basename(self.base.emit.sub_path), .{ | |
| 3293 | 3295 | .truncate = false, |
| 3294 | 3296 | .read = true, |
| 3295 | 3297 | }); |
| ... | ... | @@ -4370,7 +4372,7 @@ fn inferSdkVersion(comp: *Compilation, sdk_layout: SdkLayout) ?std.SemanticVersi |
| 4370 | 4372 | // The file/property is also available with vendored libc. |
| 4371 | 4373 | fn readSdkVersionFromSettings(arena: Allocator, dir: []const u8) ![]const u8 { |
| 4372 | 4374 | const sdk_path = try fs.path.join(arena, &.{ dir, "SDKSettings.json" }); |
| 4373 | const contents = try fs.cwd().readFileAlloc(sdk_path, arena, .limited(std.math.maxInt(u16))); | |
| 4375 | const contents = try Io.Dir.cwd().readFileAlloc(sdk_path, arena, .limited(std.math.maxInt(u16))); | |
| 4374 | 4376 | const parsed = try std.json.parseFromSlice(std.json.Value, arena, contents, .{}); |
| 4375 | 4377 | if (parsed.value.object.get("MinimalDisplayName")) |ver| return ver.string; |
| 4376 | 4378 | return error.SdkVersionFailure; |
src/link/MachO/CodeSignature.zig+1-1| ... | ... | @@ -247,7 +247,7 @@ pub fn deinit(self: *CodeSignature, allocator: Allocator) void { |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | pub fn addEntitlements(self: *CodeSignature, allocator: Allocator, path: []const u8) !void { |
| 250 | const inner = try fs.cwd().readFileAlloc(path, allocator, .limited(std.math.maxInt(u32))); | |
| 250 | const inner = try Io.Dir.cwd().readFileAlloc(path, allocator, .limited(std.math.maxInt(u32))); | |
| 251 | 251 | self.entitlements = .{ .inner = inner }; |
| 252 | 252 | } |
| 253 | 253 |
src/link/SpirV.zig+2-1| ... | ... | @@ -33,6 +33,7 @@ pub fn createEmpty( |
| 33 | 33 | options: link.File.OpenOptions, |
| 34 | 34 | ) !*Linker { |
| 35 | 35 | const gpa = comp.gpa; |
| 36 | const io = comp.io; | |
| 36 | 37 | const target = &comp.root_mod.resolved_target.result; |
| 37 | 38 | |
| 38 | 39 | assert(!comp.config.use_lld); // Caught by Compilation.Config.resolve |
| ... | ... | @@ -78,7 +79,7 @@ pub fn createEmpty( |
| 78 | 79 | }; |
| 79 | 80 | errdefer linker.deinit(); |
| 80 | 81 | |
| 81 | linker.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 82 | linker.base.file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{ | |
| 82 | 83 | .truncate = true, |
| 83 | 84 | .read = true, |
| 84 | 85 | }); |
src/link/Wasm.zig+3-1| ... | ... | @@ -2997,7 +2997,9 @@ pub fn createEmpty( |
| 2997 | 2997 | .named => |name| (try wasm.internString(name)).toOptional(), |
| 2998 | 2998 | }; |
| 2999 | 2999 | |
| 3000 | wasm.base.file = try emit.root_dir.handle.createFile(emit.sub_path, .{ | |
| 3000 | const io = comp.io; | |
| 3001 | ||
| 3002 | wasm.base.file = try emit.root_dir.handle.createFile(io, emit.sub_path, .{ | |
| 3001 | 3003 | .truncate = true, |
| 3002 | 3004 | .read = true, |
| 3003 | 3005 | .mode = if (fs.has_executable_bit) |
src/main.zig+18-18| ... | ... | @@ -713,7 +713,7 @@ const Emit = union(enum) { |
| 713 | 713 | } else e: { |
| 714 | 714 | // If there's a dirname, check that dir exists. This will give a more descriptive error than `Compilation` otherwise would. |
| 715 | 715 | if (fs.path.dirname(path)) |dir_path| { |
| 716 | var dir = fs.cwd().openDir(dir_path, .{}) catch |err| { | |
| 716 | var dir = Io.Dir.cwd().openDir(dir_path, .{}) catch |err| { | |
| 717 | 717 | fatal("unable to open output directory '{s}': {s}", .{ dir_path, @errorName(err) }); |
| 718 | 718 | }; |
| 719 | 719 | dir.close(io); |
| ... | ... | @@ -3304,7 +3304,7 @@ fn buildOutputType( |
| 3304 | 3304 | } else emit: { |
| 3305 | 3305 | // If there's a dirname, check that dir exists. This will give a more descriptive error than `Compilation` otherwise would. |
| 3306 | 3306 | if (fs.path.dirname(path)) |dir_path| { |
| 3307 | var dir = fs.cwd().openDir(dir_path, .{}) catch |err| { | |
| 3307 | var dir = Io.Dir.cwd().openDir(dir_path, .{}) catch |err| { | |
| 3308 | 3308 | fatal("unable to open output directory '{s}': {s}", .{ dir_path, @errorName(err) }); |
| 3309 | 3309 | }; |
| 3310 | 3310 | dir.close(io); |
| ... | ... | @@ -3389,7 +3389,7 @@ fn buildOutputType( |
| 3389 | 3389 | // file will not run and this temp file will be leaked. The filename |
| 3390 | 3390 | // will be a hash of its contents — so multiple invocations of |
| 3391 | 3391 | // `zig cc -` will result in the same temp file name. |
| 3392 | var f = try dirs.local_cache.handle.createFile(dump_path, .{}); | |
| 3392 | var f = try dirs.local_cache.handle.createFile(io, dump_path, .{}); | |
| 3393 | 3393 | defer f.close(io); |
| 3394 | 3394 | |
| 3395 | 3395 | // Re-using the hasher from Cache, since the functional requirements |
| ... | ... | @@ -4773,7 +4773,7 @@ fn cmdInit(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 4773 | 4773 | var ok_count: usize = 0; |
| 4774 | 4774 | |
| 4775 | 4775 | for (template_paths) |template_path| { |
| 4776 | if (templates.write(arena, fs.cwd(), sanitized_root_name, template_path, fingerprint)) |_| { | |
| 4776 | if (templates.write(arena, Io.Dir.cwd(), sanitized_root_name, template_path, fingerprint)) |_| { | |
| 4777 | 4777 | std.log.info("created {s}", .{template_path}); |
| 4778 | 4778 | ok_count += 1; |
| 4779 | 4779 | } else |err| switch (err) { |
| ... | ... | @@ -5227,7 +5227,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) |
| 5227 | 5227 | if (system_pkg_dir_path) |p| { |
| 5228 | 5228 | job_queue.global_cache = .{ |
| 5229 | 5229 | .path = p, |
| 5230 | .handle = fs.cwd().openDir(p, .{}) catch |err| { | |
| 5230 | .handle = Io.Dir.cwd().openDir(p, .{}) catch |err| { | |
| 5231 | 5231 | fatal("unable to open system package directory '{s}': {s}", .{ |
| 5232 | 5232 | p, @errorName(err), |
| 5233 | 5233 | }); |
| ... | ... | @@ -5823,7 +5823,7 @@ const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true, |
| 5823 | 5823 | /// Initialize the arguments from a Response File. "*.rsp" |
| 5824 | 5824 | fn initArgIteratorResponseFile(allocator: Allocator, resp_file_path: []const u8) !ArgIteratorResponseFile { |
| 5825 | 5825 | const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit |
| 5826 | const cmd_line = try fs.cwd().readFileAlloc(resp_file_path, allocator, .limited(max_bytes)); | |
| 5826 | const cmd_line = try Io.Dir.cwd().readFileAlloc(resp_file_path, allocator, .limited(max_bytes)); | |
| 5827 | 5827 | errdefer allocator.free(cmd_line); |
| 5828 | 5828 | |
| 5829 | 5829 | return ArgIteratorResponseFile.initTakeOwnership(allocator, cmd_line); |
| ... | ... | @@ -6187,7 +6187,7 @@ fn cmdAstCheck(arena: Allocator, io: Io, args: []const []const u8) !void { |
| 6187 | 6187 | const display_path = zig_source_path orelse "<stdin>"; |
| 6188 | 6188 | const source: [:0]const u8 = s: { |
| 6189 | 6189 | var f = if (zig_source_path) |p| file: { |
| 6190 | break :file fs.cwd().openFile(io, p, .{}) catch |err| { | |
| 6190 | break :file Io.Dir.cwd().openFile(io, p, .{}) catch |err| { | |
| 6191 | 6191 | fatal("unable to open file '{s}' for ast-check: {s}", .{ display_path, @errorName(err) }); |
| 6192 | 6192 | }; |
| 6193 | 6193 | } else Io.File.stdin(); |
| ... | ... | @@ -6494,7 +6494,7 @@ fn cmdDumpZir(arena: Allocator, io: Io, args: []const []const u8) !void { |
| 6494 | 6494 | |
| 6495 | 6495 | const cache_file = args[0]; |
| 6496 | 6496 | |
| 6497 | var f = fs.cwd().openFile(io, cache_file, .{}) catch |err| { | |
| 6497 | var f = Io.Dir.cwd().openFile(io, cache_file, .{}) catch |err| { | |
| 6498 | 6498 | fatal("unable to open zir cache file for dumping '{s}': {s}", .{ cache_file, @errorName(err) }); |
| 6499 | 6499 | }; |
| 6500 | 6500 | defer f.close(io); |
| ... | ... | @@ -6541,7 +6541,7 @@ fn cmdChangelist(arena: Allocator, io: Io, args: []const []const u8) !void { |
| 6541 | 6541 | const new_source_path = args[1]; |
| 6542 | 6542 | |
| 6543 | 6543 | const old_source = source: { |
| 6544 | var f = fs.cwd().openFile(io, old_source_path, .{}) catch |err| | |
| 6544 | var f = Io.Dir.cwd().openFile(io, old_source_path, .{}) catch |err| | |
| 6545 | 6545 | fatal("unable to open old source file '{s}': {s}", .{ old_source_path, @errorName(err) }); |
| 6546 | 6546 | defer f.close(io); |
| 6547 | 6547 | var file_reader: Io.File.Reader = f.reader(io, &stdin_buffer); |
| ... | ... | @@ -6549,7 +6549,7 @@ fn cmdChangelist(arena: Allocator, io: Io, args: []const []const u8) !void { |
| 6549 | 6549 | fatal("unable to read old source file '{s}': {s}", .{ old_source_path, @errorName(err) }); |
| 6550 | 6550 | }; |
| 6551 | 6551 | const new_source = source: { |
| 6552 | var f = fs.cwd().openFile(io, new_source_path, .{}) catch |err| | |
| 6552 | var f = Io.Dir.cwd().openFile(io, new_source_path, .{}) catch |err| | |
| 6553 | 6553 | fatal("unable to open new source file '{s}': {s}", .{ new_source_path, @errorName(err) }); |
| 6554 | 6554 | defer f.close(io); |
| 6555 | 6555 | var file_reader: Io.File.Reader = f.reader(io, &stdin_buffer); |
| ... | ... | @@ -6845,7 +6845,7 @@ fn accessFrameworkPath( |
| 6845 | 6845 | framework_dir_path, framework_name, framework_name, ext, |
| 6846 | 6846 | }); |
| 6847 | 6847 | try checked_paths.print("\n {s}", .{test_path.items}); |
| 6848 | fs.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 6848 | Io.Dir.cwd().access(test_path.items, .{}) catch |err| switch (err) { | |
| 6849 | 6849 | error.FileNotFound => continue, |
| 6850 | 6850 | else => |e| fatal("unable to search for {s} framework '{s}': {s}", .{ |
| 6851 | 6851 | ext, test_path.items, @errorName(e), |
| ... | ... | @@ -6957,7 +6957,7 @@ fn cmdFetch( |
| 6957 | 6957 | var global_cache_directory: Directory = l: { |
| 6958 | 6958 | const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena); |
| 6959 | 6959 | break :l .{ |
| 6960 | .handle = try fs.cwd().makeOpenPath(p, .{}), | |
| 6960 | .handle = try Io.Dir.cwd().makeOpenPath(p, .{}), | |
| 6961 | 6961 | .path = p, |
| 6962 | 6962 | }; |
| 6963 | 6963 | }; |
| ... | ... | @@ -7260,7 +7260,7 @@ fn findBuildRoot(arena: Allocator, options: FindBuildRootOptions) !BuildRoot { |
| 7260 | 7260 | |
| 7261 | 7261 | if (options.build_file) |bf| { |
| 7262 | 7262 | if (fs.path.dirname(bf)) |dirname| { |
| 7263 | const dir = fs.cwd().openDir(dirname, .{}) catch |err| { | |
| 7263 | const dir = Io.Dir.cwd().openDir(dirname, .{}) catch |err| { | |
| 7264 | 7264 | fatal("unable to open directory to build file from argument 'build-file', '{s}': {s}", .{ dirname, @errorName(err) }); |
| 7265 | 7265 | }; |
| 7266 | 7266 | return .{ |
| ... | ... | @@ -7272,7 +7272,7 @@ fn findBuildRoot(arena: Allocator, options: FindBuildRootOptions) !BuildRoot { |
| 7272 | 7272 | |
| 7273 | 7273 | return .{ |
| 7274 | 7274 | .build_zig_basename = build_zig_basename, |
| 7275 | .directory = .{ .path = null, .handle = fs.cwd() }, | |
| 7275 | .directory = .{ .path = null, .handle = Io.Dir.cwd() }, | |
| 7276 | 7276 | .cleanup_build_dir = null, |
| 7277 | 7277 | }; |
| 7278 | 7278 | } |
| ... | ... | @@ -7280,8 +7280,8 @@ fn findBuildRoot(arena: Allocator, options: FindBuildRootOptions) !BuildRoot { |
| 7280 | 7280 | var dirname: []const u8 = cwd_path; |
| 7281 | 7281 | while (true) { |
| 7282 | 7282 | const joined_path = try fs.path.join(arena, &[_][]const u8{ dirname, build_zig_basename }); |
| 7283 | if (fs.cwd().access(joined_path, .{})) |_| { | |
| 7284 | const dir = fs.cwd().openDir(dirname, .{}) catch |err| { | |
| 7283 | if (Io.Dir.cwd().access(joined_path, .{})) |_| { | |
| 7284 | const dir = Io.Dir.cwd().openDir(dirname, .{}) catch |err| { | |
| 7285 | 7285 | fatal("unable to open directory while searching for build.zig file, '{s}': {s}", .{ dirname, @errorName(err) }); |
| 7286 | 7286 | }; |
| 7287 | 7287 | return .{ |
| ... | ... | @@ -7443,7 +7443,7 @@ const Templates = struct { |
| 7443 | 7443 | } |
| 7444 | 7444 | }; |
| 7445 | 7445 | fn writeSimpleTemplateFile(io: Io, file_name: []const u8, comptime fmt: []const u8, args: anytype) !void { |
| 7446 | const f = try fs.cwd().createFile(file_name, .{ .exclusive = true }); | |
| 7446 | const f = try Io.Dir.cwd().createFile(io, file_name, .{ .exclusive = true }); | |
| 7447 | 7447 | defer f.close(io); |
| 7448 | 7448 | var buf: [4096]u8 = undefined; |
| 7449 | 7449 | var fw = f.writer(&buf); |
| ... | ... | @@ -7591,7 +7591,7 @@ fn addLibDirectoryWarn2( |
| 7591 | 7591 | ignore_not_found: bool, |
| 7592 | 7592 | ) void { |
| 7593 | 7593 | lib_directories.appendAssumeCapacity(.{ |
| 7594 | .handle = fs.cwd().openDir(path, .{}) catch |err| { | |
| 7594 | .handle = Io.Dir.cwd().openDir(path, .{}) catch |err| { | |
| 7595 | 7595 | if (err == error.FileNotFound and ignore_not_found) return; |
| 7596 | 7596 | warn("unable to open library directory '{s}': {s}", .{ path, @errorName(err) }); |
| 7597 | 7597 | return; |