| author | |
| committer | |
| log | dd1d15b72aa3bae4b38e2337609758ffb7a7b55a |
| tree | e6e43ed851e9a0107e851df242c23b66855151d3 |
| parent | 3204fb756980c19b7a95534acdd7a1bba837fbc3 |
24 files changed, 81 insertions(+), 78 deletions(-)
lib/compiler/aro/aro/Compilation.zig+3-3| ... | ... | @@ -154,7 +154,7 @@ gpa: Allocator, |
| 154 | 154 | /// Allocations in this arena live all the way until `Compilation.deinit`. |
| 155 | 155 | arena: Allocator, |
| 156 | 156 | io: Io, |
| 157 | cwd: std.fs.Dir, | |
| 157 | cwd: Io.Dir, | |
| 158 | 158 | diagnostics: *Diagnostics, |
| 159 | 159 | |
| 160 | 160 | sources: std.StringArrayHashMapUnmanaged(Source) = .empty, |
| ... | ... | @@ -181,7 +181,7 @@ pragma_handlers: std.StringArrayHashMapUnmanaged(*Pragma) = .empty, |
| 181 | 181 | /// Used by MS extensions which allow searching for includes relative to the directory of the main source file. |
| 182 | 182 | ms_cwd_source_id: ?Source.Id = null, |
| 183 | 183 | |
| 184 | pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: std.fs.Dir) Compilation { | |
| 184 | pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: Io.Dir) Compilation { | |
| 185 | 185 | return .{ |
| 186 | 186 | .gpa = gpa, |
| 187 | 187 | .arena = arena, |
| ... | ... | @@ -193,7 +193,7 @@ pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, |
| 193 | 193 | |
| 194 | 194 | /// Initialize Compilation with default environment, |
| 195 | 195 | /// pragma handlers and emulation mode set to target. |
| 196 | pub fn initDefault(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: std.fs.Dir) !Compilation { | |
| 196 | pub fn initDefault(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: Io.Dir) !Compilation { | |
| 197 | 197 | var comp: Compilation = .{ |
| 198 | 198 | .gpa = gpa, |
| 199 | 199 | .arena = arena, |
lib/compiler/resinator/cli.zig+1-1| ... | ... | @@ -250,7 +250,7 @@ pub const Options = struct { |
| 250 | 250 | /// worlds' situation where we'll be compatible with most use-cases |
| 251 | 251 | /// of the .rc extension being omitted from the CLI args, but still |
| 252 | 252 | /// work fine if the file itself does not have an extension. |
| 253 | pub fn maybeAppendRC(options: *Options, cwd: std.fs.Dir) !void { | |
| 253 | pub fn maybeAppendRC(options: *Options, cwd: Io.Dir) !void { | |
| 254 | 254 | switch (options.input_source) { |
| 255 | 255 | .stdio => return, |
| 256 | 256 | .filename => {}, |
lib/compiler/resinator/errors.zig+3-3| ... | ... | @@ -67,7 +67,7 @@ pub const Diagnostics = struct { |
| 67 | 67 | return @intCast(index); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | pub fn renderToStdErr(self: *Diagnostics, cwd: std.fs.Dir, source: []const u8, source_mappings: ?SourceMappings) void { | |
| 70 | pub fn renderToStdErr(self: *Diagnostics, cwd: Io.Dir, source: []const u8, source_mappings: ?SourceMappings) void { | |
| 71 | 71 | const io = self.io; |
| 72 | 72 | const stderr, const ttyconf = std.debug.lockStderrWriter(&.{}); |
| 73 | 73 | defer std.debug.unlockStderrWriter(); |
| ... | ... | @@ -903,7 +903,7 @@ pub fn renderErrorMessage( |
| 903 | 903 | io: Io, |
| 904 | 904 | writer: *std.Io.Writer, |
| 905 | 905 | tty_config: std.Io.tty.Config, |
| 906 | cwd: std.fs.Dir, | |
| 906 | cwd: Io.Dir, | |
| 907 | 907 | err_details: ErrorDetails, |
| 908 | 908 | source: []const u8, |
| 909 | 909 | strings: []const []const u8, |
| ... | ... | @@ -1100,7 +1100,7 @@ const CorrespondingLines = struct { |
| 1100 | 1100 | |
| 1101 | 1101 | pub fn init( |
| 1102 | 1102 | io: Io, |
| 1103 | cwd: std.fs.Dir, | |
| 1103 | cwd: Io.Dir, | |
| 1104 | 1104 | err_details: ErrorDetails, |
| 1105 | 1105 | line_for_comparison: []const u8, |
| 1106 | 1106 | corresponding_span: SourceMappings.CorrespondingSpan, |
lib/compiler/resinator/main.zig+1-1| ... | ... | @@ -707,7 +707,7 @@ const ErrorHandler = union(enum) { |
| 707 | 707 | pub fn emitDiagnostics( |
| 708 | 708 | self: *ErrorHandler, |
| 709 | 709 | allocator: Allocator, |
| 710 | cwd: std.fs.Dir, | |
| 710 | cwd: Io.Dir, | |
| 711 | 711 | source: []const u8, |
| 712 | 712 | diagnostics: *Diagnostics, |
| 713 | 713 | mappings: SourceMappings, |
lib/compiler/resinator/utils.zig+2-2| ... | ... | @@ -25,11 +25,11 @@ pub const UncheckedSliceWriter = struct { |
| 25 | 25 | } |
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | /// Cross-platform 'std.fs.Dir.openFile' wrapper that will always return IsDir if | |
| 28 | /// Cross-platform 'Io.Dir.openFile' wrapper that will always return IsDir if | |
| 29 | 29 | /// a directory is attempted to be opened. |
| 30 | 30 | /// TODO: Remove once https://github.com/ziglang/zig/issues/5732 is addressed. |
| 31 | 31 | pub fn openFileNotDir( |
| 32 | cwd: std.fs.Dir, | |
| 32 | cwd: Io.Dir, | |
| 33 | 33 | io: Io, |
| 34 | 34 | path: []const u8, |
| 35 | 35 | flags: Io.File.OpenFlags, |
lib/compiler/std-docs.zig+1-1| ... | ... | @@ -133,7 +133,7 @@ fn accept(context: *Context, connection: std.net.Server.Connection) void { |
| 133 | 133 | const Context = struct { |
| 134 | 134 | gpa: Allocator, |
| 135 | 135 | io: Io, |
| 136 | lib_dir: std.fs.Dir, | |
| 136 | lib_dir: Io.Dir, | |
| 137 | 137 | zig_lib_directory: []const u8, |
| 138 | 138 | zig_exe_path: []const u8, |
| 139 | 139 | global_cache_path: []const u8, |
lib/std/Build.zig+1-1| ... | ... | @@ -1699,7 +1699,7 @@ pub fn addCheckFile( |
| 1699 | 1699 | return Step.CheckFile.create(b, file_source, options); |
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | pub fn truncateFile(b: *Build, dest_path: []const u8) (fs.Dir.MakeError || fs.Dir.StatFileError)!void { | |
| 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 | 1705 | const cwd = fs.cwd(); |
lib/std/Build/Step.zig+3-3| ... | ... | @@ -505,7 +505,7 @@ pub fn evalZigProcess( |
| 505 | 505 | return result; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | /// Wrapper around `std.fs.Dir.updateFile` that handles verbose and error output. | |
| 508 | /// Wrapper around `Io.Dir.updateFile` that handles verbose and error output. | |
| 509 | 509 | pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u8) !Io.Dir.PrevStatus { |
| 510 | 510 | const b = s.owner; |
| 511 | 511 | const io = b.graph.io; |
| ... | ... | @@ -515,8 +515,8 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u |
| 515 | 515 | return s.fail("unable to update file from '{f}' to '{s}': {t}", .{ src_path, dest_path, err }); |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | /// Wrapper around `std.fs.Dir.makePathStatus` that handles verbose and error output. | |
| 519 | pub fn installDir(s: *Step, dest_path: []const u8) !std.fs.Dir.MakePathStatus { | |
| 518 | /// Wrapper around `Io.Dir.makePathStatus` that handles verbose and error output. | |
| 519 | pub fn installDir(s: *Step, dest_path: []const u8) !Io.Dir.MakePathStatus { | |
| 520 | 520 | const b = s.owner; |
| 521 | 521 | try handleVerbose(b, null, &.{ "install", "-d", dest_path }); |
| 522 | 522 | return std.fs.cwd().makePathStatus(dest_path) catch |err| |
lib/std/Build/Watch.zig+1-1| ... | ... | @@ -350,7 +350,7 @@ const Os = switch (builtin.os.tag) { |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | fn init(gpa: Allocator, path: Cache.Path) !*@This() { |
| 353 | // The following code is a drawn out NtCreateFile call. (mostly adapted from std.fs.Dir.makeOpenDirAccessMaskW) | |
| 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 | 356 | const root_fd = path.root_dir.handle.fd; |
lib/std/Io/Dir.zig+1-1| ... | ... | @@ -481,7 +481,7 @@ pub fn updateFile( |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | var buffer: [1000]u8 = undefined; // Used only when direct fd-to-fd is not available. |
| 484 | var atomic_file = try std.fs.Dir.atomicFile(.adaptFromNewApi(dest_dir), dest_path, .{ | |
| 484 | var atomic_file = try Dir.atomicFile(.adaptFromNewApi(dest_dir), dest_path, .{ | |
| 485 | 485 | .permissions = actual_permissions, |
| 486 | 486 | .write_buffer = &buffer, |
| 487 | 487 | }); |
lib/std/crypto/Certificate/Bundle.zig+2-2| ... | ... | @@ -177,7 +177,7 @@ pub fn addCertsFromDirPath( |
| 177 | 177 | cb: *Bundle, |
| 178 | 178 | gpa: Allocator, |
| 179 | 179 | io: Io, |
| 180 | dir: fs.Dir, | |
| 180 | dir: Io.Dir, | |
| 181 | 181 | sub_dir_path: []const u8, |
| 182 | 182 | ) AddCertsFromDirPathError!void { |
| 183 | 183 | var iterable_dir = try dir.openDir(sub_dir_path, .{ .iterate = true }); |
| ... | ... | @@ -200,7 +200,7 @@ pub fn addCertsFromDirPathAbsolute( |
| 200 | 200 | |
| 201 | 201 | pub const AddCertsFromDirError = AddCertsFromFilePathError; |
| 202 | 202 | |
| 203 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: fs.Dir) AddCertsFromDirError!void { | |
| 203 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: Io.Dir) AddCertsFromDirError!void { | |
| 204 | 204 | var it = iterable_dir.iterate(); |
| 205 | 205 | while (try it.next()) |entry| { |
| 206 | 206 | switch (entry.kind) { |
lib/std/dynamic_library.zig+1-1| ... | ... | @@ -157,7 +157,7 @@ pub const ElfDynLib = struct { |
| 157 | 157 | dt_gnu_hash: *elf.gnu_hash.Header, |
| 158 | 158 | }; |
| 159 | 159 | |
| 160 | fn openPath(path: []const u8, io: Io) !std.fs.Dir { | |
| 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 | 163 | var parent = if (path[0] == '/') try std.fs.cwd().openDir("/", .{}) else std.fs.cwd(); |
lib/std/fs/path.zig+2-2| ... | ... | @@ -872,7 +872,7 @@ pub fn resolve(allocator: Allocator, paths: []const []const u8) Allocator.Error! |
| 872 | 872 | |
| 873 | 873 | /// This function is like a series of `cd` statements executed one after another. |
| 874 | 874 | /// It resolves "." and ".." to the best of its ability, but will not convert relative paths to |
| 875 | /// an absolute path, use std.fs.Dir.realpath instead. | |
| 875 | /// an absolute path, use Io.Dir.realpath instead. | |
| 876 | 876 | /// ".." components may persist in the resolved path if the resolved path is relative or drive-relative. |
| 877 | 877 | /// Path separators are canonicalized to '\\' and drives are canonicalized to capital letters. |
| 878 | 878 | /// |
| ... | ... | @@ -1095,7 +1095,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) Allocator |
| 1095 | 1095 | |
| 1096 | 1096 | /// This function is like a series of `cd` statements executed one after another. |
| 1097 | 1097 | /// It resolves "." and ".." to the best of its ability, but will not convert relative paths to |
| 1098 | /// an absolute path, use std.fs.Dir.realpath instead. | |
| 1098 | /// an absolute path, use Io.Dir.realpath instead. | |
| 1099 | 1099 | /// ".." components may persist in the resolved path if the resolved path is relative. |
| 1100 | 1100 | /// The result does not have a trailing path separator. |
| 1101 | 1101 | /// This function does not perform any syscalls. Executing this series of path |
lib/std/fs/test.zig+6-7| ... | ... | @@ -9,12 +9,11 @@ const mem = std.mem; |
| 9 | 9 | const wasi = std.os.wasi; |
| 10 | 10 | const windows = std.os.windows; |
| 11 | 11 | const posix = std.posix; |
| 12 | ||
| 13 | 12 | const ArenaAllocator = std.heap.ArenaAllocator; |
| 14 | const Dir = std.fs.Dir; | |
| 13 | const Dir = std.Io.Dir; | |
| 15 | 14 | const File = std.Io.File; |
| 16 | const tmpDir = testing.tmpDir; | |
| 17 | const SymLinkFlags = std.fs.Dir.SymLinkFlags; | |
| 15 | const tmpDir = std.testing.tmpDir; | |
| 16 | const SymLinkFlags = std.Io.Dir.SymLinkFlags; | |
| 18 | 17 | |
| 19 | 18 | const PathType = enum { |
| 20 | 19 | relative, |
| ... | ... | @@ -80,7 +79,7 @@ const TestContext = struct { |
| 80 | 79 | path_sep: u8, |
| 81 | 80 | arena: ArenaAllocator, |
| 82 | 81 | tmp: testing.TmpDir, |
| 83 | dir: std.fs.Dir, | |
| 82 | dir: Io.Dir, | |
| 84 | 83 | transform_fn: *const PathType.TransformFn, |
| 85 | 84 | |
| 86 | 85 | pub fn init(path_type: PathType, path_sep: u8, allocator: mem.Allocator, transform_fn: *const PathType.TransformFn) TestContext { |
| ... | ... | @@ -1772,7 +1771,7 @@ test "open file with exclusive lock twice, make sure second lock waits" { |
| 1772 | 1771 | errdefer file.close(io); |
| 1773 | 1772 | |
| 1774 | 1773 | const S = struct { |
| 1775 | fn checkFn(dir: *fs.Dir, path: []const u8, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void { | |
| 1774 | fn checkFn(dir: *Io.Dir, path: []const u8, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void { | |
| 1776 | 1775 | started.set(); |
| 1777 | 1776 | const file1 = try dir.createFile(path, .{ .lock = .exclusive }); |
| 1778 | 1777 | |
| ... | ... | @@ -2016,7 +2015,7 @@ test "walker without fully iterating" { |
| 2016 | 2015 | try testing.expectEqual(@as(usize, 1), num_walked); |
| 2017 | 2016 | } |
| 2018 | 2017 | |
| 2019 | test "'.' and '..' in fs.Dir functions" { | |
| 2018 | test "'.' and '..' in Io.Dir functions" { | |
| 2020 | 2019 | if (native_os == .windows and builtin.cpu.arch == .aarch64) { |
| 2021 | 2020 | // https://github.com/ziglang/zig/issues/17134 |
| 2022 | 2021 | return error.SkipZigTest; |
lib/std/process/Child.zig+2-2| ... | ... | @@ -77,7 +77,7 @@ cwd: ?[]const u8, |
| 77 | 77 | /// Set to change the current working directory when spawning the child process. |
| 78 | 78 | /// This is not yet implemented for Windows. See https://github.com/ziglang/zig/issues/5190 |
| 79 | 79 | /// Once that is done, `cwd` will be deprecated in favor of this field. |
| 80 | cwd_dir: ?fs.Dir = null, | |
| 80 | cwd_dir: ?Io.Dir = null, | |
| 81 | 81 | |
| 82 | 82 | err_pipe: if (native_os == .windows) void else ?posix.fd_t, |
| 83 | 83 | |
| ... | ... | @@ -439,7 +439,7 @@ pub fn run(args: struct { |
| 439 | 439 | allocator: mem.Allocator, |
| 440 | 440 | argv: []const []const u8, |
| 441 | 441 | cwd: ?[]const u8 = null, |
| 442 | cwd_dir: ?fs.Dir = null, | |
| 442 | cwd_dir: ?Io.Dir = null, | |
| 443 | 443 | /// Required if unable to access the current env map (e.g. building a |
| 444 | 444 | /// library on some platforms). |
| 445 | 445 | env_map: ?*const EnvMap = null, |
lib/std/testing.zig+31-29| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("std.zig"); | |
| 2 | 1 | const builtin = @import("builtin"); |
| 2 | ||
| 3 | const std = @import("std.zig"); | |
| 4 | const Io = std.Io; | |
| 3 | 5 | const assert = std.debug.assert; |
| 4 | 6 | const math = std.math; |
| 5 | 7 | |
| ... | ... | @@ -28,7 +30,7 @@ pub var allocator_instance: std.heap.GeneralPurposeAllocator(.{ |
| 28 | 30 | break :b .init; |
| 29 | 31 | }; |
| 30 | 32 | |
| 31 | pub var io_instance: std.Io.Threaded = undefined; | |
| 33 | pub var io_instance: Io.Threaded = undefined; | |
| 32 | 34 | pub const io = io_instance.io(); |
| 33 | 35 | |
| 34 | 36 | /// TODO https://github.com/ziglang/zig/issues/5738 |
| ... | ... | @@ -355,7 +357,7 @@ test expectApproxEqRel { |
| 355 | 357 | /// This function is intended to be used only in tests. When the two slices are not |
| 356 | 358 | /// equal, prints diagnostics to stderr to show exactly how they are not equal (with |
| 357 | 359 | /// the differences highlighted in red), then returns a test failure error. |
| 358 | /// The colorized output is optional and controlled by the return of `std.Io.tty.Config.detect`. | |
| 360 | /// The colorized output is optional and controlled by the return of `Io.tty.Config.detect`. | |
| 359 | 361 | /// If your inputs are UTF-8 encoded strings, consider calling `expectEqualStrings` instead. |
| 360 | 362 | pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const T) !void { |
| 361 | 363 | const diff_index: usize = diff_index: { |
| ... | ... | @@ -378,8 +380,8 @@ fn failEqualSlices( |
| 378 | 380 | expected: []const T, |
| 379 | 381 | actual: []const T, |
| 380 | 382 | diff_index: usize, |
| 381 | w: *std.Io.Writer, | |
| 382 | ttyconf: std.Io.tty.Config, | |
| 383 | w: *Io.Writer, | |
| 384 | ttyconf: Io.tty.Config, | |
| 383 | 385 | ) !void { |
| 384 | 386 | try w.print("slices differ. first difference occurs at index {d} (0x{X})\n", .{ diff_index, diff_index }); |
| 385 | 387 | |
| ... | ... | @@ -464,11 +466,11 @@ fn SliceDiffer(comptime T: type) type { |
| 464 | 466 | start_index: usize, |
| 465 | 467 | expected: []const T, |
| 466 | 468 | actual: []const T, |
| 467 | ttyconf: std.Io.tty.Config, | |
| 469 | ttyconf: Io.tty.Config, | |
| 468 | 470 | |
| 469 | 471 | const Self = @This(); |
| 470 | 472 | |
| 471 | pub fn write(self: Self, writer: *std.Io.Writer) !void { | |
| 473 | pub fn write(self: Self, writer: *Io.Writer) !void { | |
| 472 | 474 | for (self.expected, 0..) |value, i| { |
| 473 | 475 | const full_index = self.start_index + i; |
| 474 | 476 | const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true; |
| ... | ... | @@ -487,9 +489,9 @@ fn SliceDiffer(comptime T: type) type { |
| 487 | 489 | const BytesDiffer = struct { |
| 488 | 490 | expected: []const u8, |
| 489 | 491 | actual: []const u8, |
| 490 | ttyconf: std.Io.tty.Config, | |
| 492 | ttyconf: Io.tty.Config, | |
| 491 | 493 | |
| 492 | pub fn write(self: BytesDiffer, writer: *std.Io.Writer) !void { | |
| 494 | pub fn write(self: BytesDiffer, writer: *Io.Writer) !void { | |
| 493 | 495 | var expected_iterator = std.mem.window(u8, self.expected, 16, 16); |
| 494 | 496 | var row: usize = 0; |
| 495 | 497 | while (expected_iterator.next()) |chunk| { |
| ... | ... | @@ -535,7 +537,7 @@ const BytesDiffer = struct { |
| 535 | 537 | } |
| 536 | 538 | } |
| 537 | 539 | |
| 538 | fn writeDiff(self: BytesDiffer, writer: *std.Io.Writer, comptime fmt: []const u8, args: anytype, diff: bool) !void { | |
| 540 | fn writeDiff(self: BytesDiffer, writer: *Io.Writer, comptime fmt: []const u8, args: anytype, diff: bool) !void { | |
| 539 | 541 | if (diff) try self.ttyconf.setColor(writer, .red); |
| 540 | 542 | try writer.print(fmt, args); |
| 541 | 543 | if (diff) try self.ttyconf.setColor(writer, .reset); |
| ... | ... | @@ -605,8 +607,8 @@ pub fn expect(ok: bool) !void { |
| 605 | 607 | } |
| 606 | 608 | |
| 607 | 609 | pub const TmpDir = struct { |
| 608 | dir: std.fs.Dir, | |
| 609 | parent_dir: std.fs.Dir, | |
| 610 | dir: Io.Dir, | |
| 611 | parent_dir: Io.Dir, | |
| 610 | 612 | sub_path: [sub_path_len]u8, |
| 611 | 613 | |
| 612 | 614 | const random_bytes_count = 12; |
| ... | ... | @@ -620,7 +622,7 @@ pub const TmpDir = struct { |
| 620 | 622 | } |
| 621 | 623 | }; |
| 622 | 624 | |
| 623 | pub fn tmpDir(opts: std.fs.Dir.OpenOptions) TmpDir { | |
| 625 | pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir { | |
| 624 | 626 | var random_bytes: [TmpDir.random_bytes_count]u8 = undefined; |
| 625 | 627 | std.crypto.random.bytes(&random_bytes); |
| 626 | 628 | var sub_path: [TmpDir.sub_path_len]u8 = undefined; |
| ... | ... | @@ -929,7 +931,7 @@ test "expectEqualDeep primitive type" { |
| 929 | 931 | a, |
| 930 | 932 | b, |
| 931 | 933 | |
| 932 | pub fn format(self: @This(), writer: *std.Io.Writer) !void { | |
| 934 | pub fn format(self: @This(), writer: *Io.Writer) !void { | |
| 933 | 935 | try writer.writeAll(@tagName(self)); |
| 934 | 936 | } |
| 935 | 937 | }; |
| ... | ... | @@ -1160,7 +1162,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime |
| 1160 | 1162 | } else |err| switch (err) { |
| 1161 | 1163 | error.OutOfMemory => { |
| 1162 | 1164 | if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) { |
| 1163 | const tty_config: std.Io.tty.Config = .detect(.stderr()); | |
| 1165 | const tty_config: Io.tty.Config = .detect(.stderr()); | |
| 1164 | 1166 | print( |
| 1165 | 1167 | "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {f}", |
| 1166 | 1168 | .{ |
| ... | ... | @@ -1220,14 +1222,14 @@ pub inline fn fuzz( |
| 1220 | 1222 | return @import("root").fuzz(context, testOne, options); |
| 1221 | 1223 | } |
| 1222 | 1224 | |
| 1223 | /// A `std.Io.Reader` that writes a predetermined list of buffers during `stream`. | |
| 1225 | /// A `Io.Reader` that writes a predetermined list of buffers during `stream`. | |
| 1224 | 1226 | pub const Reader = struct { |
| 1225 | 1227 | calls: []const Call, |
| 1226 | interface: std.Io.Reader, | |
| 1228 | interface: Io.Reader, | |
| 1227 | 1229 | next_call_index: usize, |
| 1228 | 1230 | next_offset: usize, |
| 1229 | 1231 | /// Further reduces how many bytes are written in each `stream` call. |
| 1230 | artificial_limit: std.Io.Limit = .unlimited, | |
| 1232 | artificial_limit: Io.Limit = .unlimited, | |
| 1231 | 1233 | |
| 1232 | 1234 | pub const Call = struct { |
| 1233 | 1235 | buffer: []const u8, |
| ... | ... | @@ -1247,7 +1249,7 @@ pub const Reader = struct { |
| 1247 | 1249 | }; |
| 1248 | 1250 | } |
| 1249 | 1251 | |
| 1250 | fn stream(io_r: *std.Io.Reader, w: *std.Io.Writer, limit: std.Io.Limit) std.Io.Reader.StreamError!usize { | |
| 1252 | fn stream(io_r: *Io.Reader, w: *Io.Writer, limit: Io.Limit) Io.Reader.StreamError!usize { | |
| 1251 | 1253 | const r: *Reader = @alignCast(@fieldParentPtr("interface", io_r)); |
| 1252 | 1254 | if (r.calls.len - r.next_call_index == 0) return error.EndOfStream; |
| 1253 | 1255 | const call = r.calls[r.next_call_index]; |
| ... | ... | @@ -1262,13 +1264,13 @@ pub const Reader = struct { |
| 1262 | 1264 | } |
| 1263 | 1265 | }; |
| 1264 | 1266 | |
| 1265 | /// A `std.Io.Reader` that gets its data from another `std.Io.Reader`, and always | |
| 1267 | /// A `Io.Reader` that gets its data from another `Io.Reader`, and always | |
| 1266 | 1268 | /// writes to its own buffer (and returns 0) during `stream` and `readVec`. |
| 1267 | 1269 | pub const ReaderIndirect = struct { |
| 1268 | in: *std.Io.Reader, | |
| 1269 | interface: std.Io.Reader, | |
| 1270 | in: *Io.Reader, | |
| 1271 | interface: Io.Reader, | |
| 1270 | 1272 | |
| 1271 | pub fn init(in: *std.Io.Reader, buffer: []u8) ReaderIndirect { | |
| 1273 | pub fn init(in: *Io.Reader, buffer: []u8) ReaderIndirect { | |
| 1272 | 1274 | return .{ |
| 1273 | 1275 | .in = in, |
| 1274 | 1276 | .interface = .{ |
| ... | ... | @@ -1283,17 +1285,17 @@ pub const ReaderIndirect = struct { |
| 1283 | 1285 | }; |
| 1284 | 1286 | } |
| 1285 | 1287 | |
| 1286 | fn readVec(r: *std.Io.Reader, _: [][]u8) std.Io.Reader.Error!usize { | |
| 1288 | fn readVec(r: *Io.Reader, _: [][]u8) Io.Reader.Error!usize { | |
| 1287 | 1289 | try streamInner(r); |
| 1288 | 1290 | return 0; |
| 1289 | 1291 | } |
| 1290 | 1292 | |
| 1291 | fn stream(r: *std.Io.Reader, _: *std.Io.Writer, _: std.Io.Limit) std.Io.Reader.StreamError!usize { | |
| 1293 | fn stream(r: *Io.Reader, _: *Io.Writer, _: Io.Limit) Io.Reader.StreamError!usize { | |
| 1292 | 1294 | try streamInner(r); |
| 1293 | 1295 | return 0; |
| 1294 | 1296 | } |
| 1295 | 1297 | |
| 1296 | fn streamInner(r: *std.Io.Reader) std.Io.Reader.Error!void { | |
| 1298 | fn streamInner(r: *Io.Reader) Io.Reader.Error!void { | |
| 1297 | 1299 | const r_indirect: *ReaderIndirect = @alignCast(@fieldParentPtr("interface", r)); |
| 1298 | 1300 | |
| 1299 | 1301 | // If there's no room remaining in the buffer at all, make room. |
| ... | ... | @@ -1301,12 +1303,12 @@ pub const ReaderIndirect = struct { |
| 1301 | 1303 | try r.rebase(r.buffer.len); |
| 1302 | 1304 | } |
| 1303 | 1305 | |
| 1304 | var writer: std.Io.Writer = .{ | |
| 1306 | var writer: Io.Writer = .{ | |
| 1305 | 1307 | .buffer = r.buffer, |
| 1306 | 1308 | .end = r.end, |
| 1307 | 1309 | .vtable = &.{ |
| 1308 | .drain = std.Io.Writer.unreachableDrain, | |
| 1309 | .rebase = std.Io.Writer.unreachableRebase, | |
| 1310 | .drain = Io.Writer.unreachableDrain, | |
| 1311 | .rebase = Io.Writer.unreachableRebase, | |
| 1310 | 1312 | }, |
| 1311 | 1313 | }; |
| 1312 | 1314 | defer r.end = writer.end; |
lib/std/zig/WindowsSdk.zig+4-4| ... | ... | @@ -77,7 +77,7 @@ pub fn free(sdk: WindowsSdk, allocator: Allocator) void { |
| 77 | 77 | /// and a version. Returns slice of version strings sorted in descending order. |
| 78 | 78 | /// Caller owns result. |
| 79 | 79 | fn iterateAndFilterByVersion( |
| 80 | iterator: *std.fs.Dir.Iterator, | |
| 80 | iterator: *Io.Dir.Iterator, | |
| 81 | 81 | allocator: Allocator, |
| 82 | 82 | prefix: []const u8, |
| 83 | 83 | ) error{OutOfMemory}![][]const u8 { |
| ... | ... | @@ -608,7 +608,7 @@ pub const Installation = struct { |
| 608 | 608 | }; |
| 609 | 609 | |
| 610 | 610 | const MsvcLibDir = struct { |
| 611 | fn findInstancesDirViaSetup(allocator: Allocator) error{ OutOfMemory, PathNotFound }!std.fs.Dir { | |
| 611 | fn findInstancesDirViaSetup(allocator: Allocator) error{ OutOfMemory, PathNotFound }!Io.Dir { | |
| 612 | 612 | const vs_setup_key_path = "SOFTWARE\\Microsoft\\VisualStudio\\Setup"; |
| 613 | 613 | const vs_setup_key = RegistryWtf8.openKey(windows.HKEY_LOCAL_MACHINE, vs_setup_key_path, .{}) catch |err| switch (err) { |
| 614 | 614 | error.KeyNotFound => return error.PathNotFound, |
| ... | ... | @@ -633,7 +633,7 @@ const MsvcLibDir = struct { |
| 633 | 633 | return std.fs.openDirAbsolute(instances_path, .{ .iterate = true }) catch return error.PathNotFound; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | fn findInstancesDirViaCLSID(allocator: Allocator) error{ OutOfMemory, PathNotFound }!std.fs.Dir { | |
| 636 | fn findInstancesDirViaCLSID(allocator: Allocator) error{ OutOfMemory, PathNotFound }!Io.Dir { | |
| 637 | 637 | const setup_configuration_clsid = "{177f0c4a-1cd3-4de7-a32c-71dbbb9fa36d}"; |
| 638 | 638 | const setup_config_key = RegistryWtf8.openKey(windows.HKEY_CLASSES_ROOT, "CLSID\\" ++ setup_configuration_clsid, .{}) catch |err| switch (err) { |
| 639 | 639 | error.KeyNotFound => return error.PathNotFound, |
| ... | ... | @@ -669,7 +669,7 @@ const MsvcLibDir = struct { |
| 669 | 669 | return std.fs.openDirAbsolute(instances_path, .{ .iterate = true }) catch return error.PathNotFound; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | fn findInstancesDir(allocator: Allocator) error{ OutOfMemory, PathNotFound }!std.fs.Dir { | |
| 672 | fn findInstancesDir(allocator: Allocator) error{ OutOfMemory, PathNotFound }!Io.Dir { | |
| 673 | 673 | // First, try getting the packages cache path from the registry. |
| 674 | 674 | // This only seems to exist when the path is different from the default. |
| 675 | 675 | method1: { |
lib/std/zig/llvm/Builder.zig+1-1| ... | ... | @@ -9582,7 +9582,7 @@ pub fn dump(b: *Builder) void { |
| 9582 | 9582 | b.printToFile(stderr, &buffer) catch {}; |
| 9583 | 9583 | } |
| 9584 | 9584 | |
| 9585 | pub fn printToFilePath(b: *Builder, io: Io, dir: std.fs.Dir, path: []const u8) !void { | |
| 9585 | pub fn printToFilePath(b: *Builder, io: Io, dir: Io.Dir, path: []const u8) !void { | |
| 9586 | 9586 | var buffer: [4000]u8 = undefined; |
| 9587 | 9587 | const file = try dir.createFile(io, path, .{}); |
| 9588 | 9588 | defer file.close(io); |
lib/std/zip.zig+3-2| ... | ... | @@ -7,6 +7,7 @@ const builtin = @import("builtin"); |
| 7 | 7 | const is_le = builtin.target.cpu.arch.endian() == .little; |
| 8 | 8 | |
| 9 | 9 | const std = @import("std"); |
| 10 | const Io = std.Io; | |
| 10 | 11 | const File = std.Io.File; |
| 11 | 12 | const Writer = std.Io.Writer; |
| 12 | 13 | const Reader = std.Io.Reader; |
| ... | ... | @@ -461,7 +462,7 @@ pub const Iterator = struct { |
| 461 | 462 | stream: *File.Reader, |
| 462 | 463 | options: ExtractOptions, |
| 463 | 464 | filename_buf: []u8, |
| 464 | dest: std.fs.Dir, | |
| 465 | dest: Io.Dir, | |
| 465 | 466 | ) !void { |
| 466 | 467 | if (filename_buf.len < self.filename_len) |
| 467 | 468 | return error.ZipInsufficientBuffer; |
| ... | ... | @@ -650,7 +651,7 @@ pub const ExtractOptions = struct { |
| 650 | 651 | }; |
| 651 | 652 | |
| 652 | 653 | /// Extract the zipped files to the given `dest` directory. |
| 653 | pub fn extract(dest: std.fs.Dir, fr: *File.Reader, options: ExtractOptions) !void { | |
| 654 | pub fn extract(dest: Io.Dir, fr: *File.Reader, options: ExtractOptions) !void { | |
| 654 | 655 | if (options.verify_checksums) @panic("TODO unimplemented"); |
| 655 | 656 | |
| 656 | 657 | var iter = try Iterator.init(fr); |
src/Compilation.zig+2-2| ... | ... | @@ -446,7 +446,7 @@ pub const Path = struct { |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /// Given a `Path`, returns the directory handle and sub path to be used to open the path. |
| 449 | pub fn openInfo(p: Path, dirs: Directories) struct { fs.Dir, []const u8 } { | |
| 449 | pub fn openInfo(p: Path, dirs: Directories) struct { Io.Dir, []const u8 } { | |
| 450 | 450 | const dir = switch (p.root) { |
| 451 | 451 | .none => { |
| 452 | 452 | const cwd_sub_path = absToCwdRelative(p.sub_path, dirs.cwd); |
| ... | ... | @@ -1872,7 +1872,7 @@ pub const CreateDiagnostic = union(enum) { |
| 1872 | 1872 | pub const CreateCachePath = struct { |
| 1873 | 1873 | which: enum { local, global }, |
| 1874 | 1874 | sub: []const u8, |
| 1875 | err: (fs.Dir.MakeError || fs.Dir.OpenError || fs.Dir.StatFileError), | |
| 1875 | err: (Io.Dir.MakeError || Io.Dir.OpenError || Io.Dir.StatFileError), | |
| 1876 | 1876 | }; |
| 1877 | 1877 | pub fn format(diag: CreateDiagnostic, w: *Writer) Writer.Error!void { |
| 1878 | 1878 | switch (diag) { |
src/Package/Fetch/git.zig+2-2| ... | ... | @@ -214,7 +214,7 @@ pub const Repository = struct { |
| 214 | 214 | pub fn checkout( |
| 215 | 215 | repository: *Repository, |
| 216 | 216 | io: Io, |
| 217 | worktree: std.fs.Dir, | |
| 217 | worktree: Io.Dir, | |
| 218 | 218 | commit_oid: Oid, |
| 219 | 219 | diagnostics: *Diagnostics, |
| 220 | 220 | ) !void { |
| ... | ... | @@ -231,7 +231,7 @@ pub const Repository = struct { |
| 231 | 231 | fn checkoutTree( |
| 232 | 232 | repository: *Repository, |
| 233 | 233 | io: Io, |
| 234 | dir: std.fs.Dir, | |
| 234 | dir: Io.Dir, | |
| 235 | 235 | tree_oid: Oid, |
| 236 | 236 | current_path: []const u8, |
| 237 | 237 | diagnostics: *Diagnostics, |
src/fmt.zig+3-3| ... | ... | @@ -204,7 +204,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) ! |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) !void { | |
| 207 | fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: Io.Dir, sub_path: []const u8) !void { | |
| 208 | 208 | fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) { |
| 209 | 209 | error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path), |
| 210 | 210 | else => { |
| ... | ... | @@ -219,7 +219,7 @@ fn fmtPathDir( |
| 219 | 219 | fmt: *Fmt, |
| 220 | 220 | file_path: []const u8, |
| 221 | 221 | check_mode: bool, |
| 222 | parent_dir: fs.Dir, | |
| 222 | parent_dir: Io.Dir, | |
| 223 | 223 | parent_sub_path: []const u8, |
| 224 | 224 | ) !void { |
| 225 | 225 | const io = fmt.io; |
| ... | ... | @@ -257,7 +257,7 @@ fn fmtPathFile( |
| 257 | 257 | fmt: *Fmt, |
| 258 | 258 | file_path: []const u8, |
| 259 | 259 | check_mode: bool, |
| 260 | dir: fs.Dir, | |
| 260 | dir: Io.Dir, | |
| 261 | 261 | sub_path: []const u8, |
| 262 | 262 | ) !void { |
| 263 | 263 | const io = fmt.io; |
src/link/Lld.zig+4-3| ... | ... | @@ -400,7 +400,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 400 | 400 | // regarding eliding redundant object -> object transformations. |
| 401 | 401 | return error.NoObjectsToLink; |
| 402 | 402 | }; |
| 403 | try std.fs.Dir.copyFile( | |
| 403 | try Io.Dir.copyFile( | |
| 404 | 404 | the_object_path.root_dir.handle, |
| 405 | 405 | the_object_path.sub_path, |
| 406 | 406 | directory.handle, |
| ... | ... | @@ -816,7 +816,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { |
| 816 | 816 | // regarding eliding redundant object -> object transformations. |
| 817 | 817 | return error.NoObjectsToLink; |
| 818 | 818 | }; |
| 819 | try std.fs.Dir.copyFile( | |
| 819 | try Io.Dir.copyFile( | |
| 820 | 820 | the_object_path.root_dir.handle, |
| 821 | 821 | the_object_path.sub_path, |
| 822 | 822 | directory.handle, |
| ... | ... | @@ -1371,7 +1371,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { |
| 1371 | 1371 | // regarding eliding redundant object -> object transformations. |
| 1372 | 1372 | return error.NoObjectsToLink; |
| 1373 | 1373 | }; |
| 1374 | try fs.Dir.copyFile( | |
| 1374 | try Io.Dir.copyFile( | |
| 1375 | 1375 | the_object_path.root_dir.handle, |
| 1376 | 1376 | the_object_path.sub_path, |
| 1377 | 1377 | directory.handle, |
| ... | ... | @@ -1692,6 +1692,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | const std = @import("std"); |
| 1695 | const Io = std.Io; | |
| 1695 | 1696 | const Allocator = std.mem.Allocator; |
| 1696 | 1697 | const Cache = std.Build.Cache; |
| 1697 | 1698 | const allocPrint = std.fmt.allocPrint; |
src/link/MachO.zig+1-1| ... | ... | @@ -3573,7 +3573,7 @@ pub fn getTarget(self: *const MachO) *const std.Target { |
| 3573 | 3573 | /// into a new inode, remove the original file, and rename the copy to match |
| 3574 | 3574 | /// the original file. This is super messy, but there doesn't seem any other |
| 3575 | 3575 | /// way to please the XNU. |
| 3576 | pub fn invalidateKernelCache(dir: fs.Dir, sub_path: []const u8) !void { | |
| 3576 | pub fn invalidateKernelCache(dir: Io.Dir, sub_path: []const u8) !void { | |
| 3577 | 3577 | const tracy = trace(@src()); |
| 3578 | 3578 | defer tracy.end(); |
| 3579 | 3579 | if (builtin.target.os.tag.isDarwin() and builtin.target.cpu.arch == .aarch64) { |