mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
update all occurrences of std.fs.Dir to std.Io.Dir
This commit is contained in:
Vendored
+3
-3
@@ -154,7 +154,7 @@ gpa: Allocator,
|
||||
/// Allocations in this arena live all the way until `Compilation.deinit`.
|
||||
arena: Allocator,
|
||||
io: Io,
|
||||
cwd: std.fs.Dir,
|
||||
cwd: Io.Dir,
|
||||
diagnostics: *Diagnostics,
|
||||
|
||||
sources: std.StringArrayHashMapUnmanaged(Source) = .empty,
|
||||
@@ -181,7 +181,7 @@ pragma_handlers: std.StringArrayHashMapUnmanaged(*Pragma) = .empty,
|
||||
/// Used by MS extensions which allow searching for includes relative to the directory of the main source file.
|
||||
ms_cwd_source_id: ?Source.Id = null,
|
||||
|
||||
pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: std.fs.Dir) Compilation {
|
||||
pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: Io.Dir) Compilation {
|
||||
return .{
|
||||
.gpa = gpa,
|
||||
.arena = arena,
|
||||
@@ -193,7 +193,7 @@ pub fn init(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics,
|
||||
|
||||
/// Initialize Compilation with default environment,
|
||||
/// pragma handlers and emulation mode set to target.
|
||||
pub fn initDefault(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: std.fs.Dir) !Compilation {
|
||||
pub fn initDefault(gpa: Allocator, arena: Allocator, io: Io, diagnostics: *Diagnostics, cwd: Io.Dir) !Compilation {
|
||||
var comp: Compilation = .{
|
||||
.gpa = gpa,
|
||||
.arena = arena,
|
||||
|
||||
Vendored
+1
-1
@@ -250,7 +250,7 @@ pub const Options = struct {
|
||||
/// worlds' situation where we'll be compatible with most use-cases
|
||||
/// of the .rc extension being omitted from the CLI args, but still
|
||||
/// work fine if the file itself does not have an extension.
|
||||
pub fn maybeAppendRC(options: *Options, cwd: std.fs.Dir) !void {
|
||||
pub fn maybeAppendRC(options: *Options, cwd: Io.Dir) !void {
|
||||
switch (options.input_source) {
|
||||
.stdio => return,
|
||||
.filename => {},
|
||||
|
||||
Vendored
+3
-3
@@ -67,7 +67,7 @@ pub const Diagnostics = struct {
|
||||
return @intCast(index);
|
||||
}
|
||||
|
||||
pub fn renderToStdErr(self: *Diagnostics, cwd: std.fs.Dir, source: []const u8, source_mappings: ?SourceMappings) void {
|
||||
pub fn renderToStdErr(self: *Diagnostics, cwd: Io.Dir, source: []const u8, source_mappings: ?SourceMappings) void {
|
||||
const io = self.io;
|
||||
const stderr, const ttyconf = std.debug.lockStderrWriter(&.{});
|
||||
defer std.debug.unlockStderrWriter();
|
||||
@@ -903,7 +903,7 @@ pub fn renderErrorMessage(
|
||||
io: Io,
|
||||
writer: *std.Io.Writer,
|
||||
tty_config: std.Io.tty.Config,
|
||||
cwd: std.fs.Dir,
|
||||
cwd: Io.Dir,
|
||||
err_details: ErrorDetails,
|
||||
source: []const u8,
|
||||
strings: []const []const u8,
|
||||
@@ -1100,7 +1100,7 @@ const CorrespondingLines = struct {
|
||||
|
||||
pub fn init(
|
||||
io: Io,
|
||||
cwd: std.fs.Dir,
|
||||
cwd: Io.Dir,
|
||||
err_details: ErrorDetails,
|
||||
line_for_comparison: []const u8,
|
||||
corresponding_span: SourceMappings.CorrespondingSpan,
|
||||
|
||||
Vendored
+1
-1
@@ -707,7 +707,7 @@ const ErrorHandler = union(enum) {
|
||||
pub fn emitDiagnostics(
|
||||
self: *ErrorHandler,
|
||||
allocator: Allocator,
|
||||
cwd: std.fs.Dir,
|
||||
cwd: Io.Dir,
|
||||
source: []const u8,
|
||||
diagnostics: *Diagnostics,
|
||||
mappings: SourceMappings,
|
||||
|
||||
Vendored
+2
-2
@@ -25,11 +25,11 @@ pub const UncheckedSliceWriter = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// Cross-platform 'std.fs.Dir.openFile' wrapper that will always return IsDir if
|
||||
/// Cross-platform 'Io.Dir.openFile' wrapper that will always return IsDir if
|
||||
/// a directory is attempted to be opened.
|
||||
/// TODO: Remove once https://github.com/ziglang/zig/issues/5732 is addressed.
|
||||
pub fn openFileNotDir(
|
||||
cwd: std.fs.Dir,
|
||||
cwd: Io.Dir,
|
||||
io: Io,
|
||||
path: []const u8,
|
||||
flags: Io.File.OpenFlags,
|
||||
|
||||
@@ -133,7 +133,7 @@ fn accept(context: *Context, connection: std.net.Server.Connection) void {
|
||||
const Context = struct {
|
||||
gpa: Allocator,
|
||||
io: Io,
|
||||
lib_dir: std.fs.Dir,
|
||||
lib_dir: Io.Dir,
|
||||
zig_lib_directory: []const u8,
|
||||
zig_exe_path: []const u8,
|
||||
global_cache_path: []const u8,
|
||||
|
||||
+1
-1
@@ -1699,7 +1699,7 @@ pub fn addCheckFile(
|
||||
return Step.CheckFile.create(b, file_source, options);
|
||||
}
|
||||
|
||||
pub fn truncateFile(b: *Build, dest_path: []const u8) (fs.Dir.MakeError || fs.Dir.StatFileError)!void {
|
||||
pub fn truncateFile(b: *Build, dest_path: []const u8) (Io.Dir.MakeError || Io.Dir.StatFileError)!void {
|
||||
const io = b.graph.io;
|
||||
if (b.verbose) log.info("truncate {s}", .{dest_path});
|
||||
const cwd = fs.cwd();
|
||||
|
||||
@@ -505,7 +505,7 @@ pub fn evalZigProcess(
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Wrapper around `std.fs.Dir.updateFile` that handles verbose and error output.
|
||||
/// Wrapper around `Io.Dir.updateFile` that handles verbose and error output.
|
||||
pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u8) !Io.Dir.PrevStatus {
|
||||
const b = s.owner;
|
||||
const io = b.graph.io;
|
||||
@@ -515,8 +515,8 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u
|
||||
return s.fail("unable to update file from '{f}' to '{s}': {t}", .{ src_path, dest_path, err });
|
||||
}
|
||||
|
||||
/// Wrapper around `std.fs.Dir.makePathStatus` that handles verbose and error output.
|
||||
pub fn installDir(s: *Step, dest_path: []const u8) !std.fs.Dir.MakePathStatus {
|
||||
/// Wrapper around `Io.Dir.makePathStatus` that handles verbose and error output.
|
||||
pub fn installDir(s: *Step, dest_path: []const u8) !Io.Dir.MakePathStatus {
|
||||
const b = s.owner;
|
||||
try handleVerbose(b, null, &.{ "install", "-d", dest_path });
|
||||
return std.fs.cwd().makePathStatus(dest_path) catch |err|
|
||||
|
||||
@@ -350,7 +350,7 @@ const Os = switch (builtin.os.tag) {
|
||||
}
|
||||
|
||||
fn init(gpa: Allocator, path: Cache.Path) !*@This() {
|
||||
// The following code is a drawn out NtCreateFile call. (mostly adapted from std.fs.Dir.makeOpenDirAccessMaskW)
|
||||
// The following code is a drawn out NtCreateFile call. (mostly adapted from Io.Dir.makeOpenDirAccessMaskW)
|
||||
// It's necessary in order to get the specific flags that are required when calling ReadDirectoryChangesW.
|
||||
var dir_handle: windows.HANDLE = undefined;
|
||||
const root_fd = path.root_dir.handle.fd;
|
||||
|
||||
+1
-1
@@ -481,7 +481,7 @@ pub fn updateFile(
|
||||
}
|
||||
|
||||
var buffer: [1000]u8 = undefined; // Used only when direct fd-to-fd is not available.
|
||||
var atomic_file = try std.fs.Dir.atomicFile(.adaptFromNewApi(dest_dir), dest_path, .{
|
||||
var atomic_file = try Dir.atomicFile(.adaptFromNewApi(dest_dir), dest_path, .{
|
||||
.permissions = actual_permissions,
|
||||
.write_buffer = &buffer,
|
||||
});
|
||||
|
||||
@@ -177,7 +177,7 @@ pub fn addCertsFromDirPath(
|
||||
cb: *Bundle,
|
||||
gpa: Allocator,
|
||||
io: Io,
|
||||
dir: fs.Dir,
|
||||
dir: Io.Dir,
|
||||
sub_dir_path: []const u8,
|
||||
) AddCertsFromDirPathError!void {
|
||||
var iterable_dir = try dir.openDir(sub_dir_path, .{ .iterate = true });
|
||||
@@ -200,7 +200,7 @@ pub fn addCertsFromDirPathAbsolute(
|
||||
|
||||
pub const AddCertsFromDirError = AddCertsFromFilePathError;
|
||||
|
||||
pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: fs.Dir) AddCertsFromDirError!void {
|
||||
pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: Io.Dir) AddCertsFromDirError!void {
|
||||
var it = iterable_dir.iterate();
|
||||
while (try it.next()) |entry| {
|
||||
switch (entry.kind) {
|
||||
|
||||
@@ -157,7 +157,7 @@ pub const ElfDynLib = struct {
|
||||
dt_gnu_hash: *elf.gnu_hash.Header,
|
||||
};
|
||||
|
||||
fn openPath(path: []const u8, io: Io) !std.fs.Dir {
|
||||
fn openPath(path: []const u8, io: Io) !Io.Dir {
|
||||
if (path.len == 0) return error.NotDir;
|
||||
var parts = std.mem.tokenizeScalar(u8, path, '/');
|
||||
var parent = if (path[0] == '/') try std.fs.cwd().openDir("/", .{}) else std.fs.cwd();
|
||||
|
||||
+2
-2
@@ -872,7 +872,7 @@ pub fn resolve(allocator: Allocator, paths: []const []const u8) Allocator.Error!
|
||||
|
||||
/// This function is like a series of `cd` statements executed one after another.
|
||||
/// It resolves "." and ".." to the best of its ability, but will not convert relative paths to
|
||||
/// an absolute path, use std.fs.Dir.realpath instead.
|
||||
/// an absolute path, use Io.Dir.realpath instead.
|
||||
/// ".." components may persist in the resolved path if the resolved path is relative or drive-relative.
|
||||
/// Path separators are canonicalized to '\\' and drives are canonicalized to capital letters.
|
||||
///
|
||||
@@ -1095,7 +1095,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) Allocator
|
||||
|
||||
/// This function is like a series of `cd` statements executed one after another.
|
||||
/// It resolves "." and ".." to the best of its ability, but will not convert relative paths to
|
||||
/// an absolute path, use std.fs.Dir.realpath instead.
|
||||
/// an absolute path, use Io.Dir.realpath instead.
|
||||
/// ".." components may persist in the resolved path if the resolved path is relative.
|
||||
/// The result does not have a trailing path separator.
|
||||
/// This function does not perform any syscalls. Executing this series of path
|
||||
|
||||
+6
-7
@@ -9,12 +9,11 @@ const mem = std.mem;
|
||||
const wasi = std.os.wasi;
|
||||
const windows = std.os.windows;
|
||||
const posix = std.posix;
|
||||
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
const Dir = std.fs.Dir;
|
||||
const Dir = std.Io.Dir;
|
||||
const File = std.Io.File;
|
||||
const tmpDir = testing.tmpDir;
|
||||
const SymLinkFlags = std.fs.Dir.SymLinkFlags;
|
||||
const tmpDir = std.testing.tmpDir;
|
||||
const SymLinkFlags = std.Io.Dir.SymLinkFlags;
|
||||
|
||||
const PathType = enum {
|
||||
relative,
|
||||
@@ -80,7 +79,7 @@ const TestContext = struct {
|
||||
path_sep: u8,
|
||||
arena: ArenaAllocator,
|
||||
tmp: testing.TmpDir,
|
||||
dir: std.fs.Dir,
|
||||
dir: Io.Dir,
|
||||
transform_fn: *const PathType.TransformFn,
|
||||
|
||||
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" {
|
||||
errdefer file.close(io);
|
||||
|
||||
const S = struct {
|
||||
fn checkFn(dir: *fs.Dir, path: []const u8, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void {
|
||||
fn checkFn(dir: *Io.Dir, path: []const u8, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void {
|
||||
started.set();
|
||||
const file1 = try dir.createFile(path, .{ .lock = .exclusive });
|
||||
|
||||
@@ -2016,7 +2015,7 @@ test "walker without fully iterating" {
|
||||
try testing.expectEqual(@as(usize, 1), num_walked);
|
||||
}
|
||||
|
||||
test "'.' and '..' in fs.Dir functions" {
|
||||
test "'.' and '..' in Io.Dir functions" {
|
||||
if (native_os == .windows and builtin.cpu.arch == .aarch64) {
|
||||
// https://github.com/ziglang/zig/issues/17134
|
||||
return error.SkipZigTest;
|
||||
|
||||
@@ -77,7 +77,7 @@ cwd: ?[]const u8,
|
||||
/// Set to change the current working directory when spawning the child process.
|
||||
/// This is not yet implemented for Windows. See https://github.com/ziglang/zig/issues/5190
|
||||
/// Once that is done, `cwd` will be deprecated in favor of this field.
|
||||
cwd_dir: ?fs.Dir = null,
|
||||
cwd_dir: ?Io.Dir = null,
|
||||
|
||||
err_pipe: if (native_os == .windows) void else ?posix.fd_t,
|
||||
|
||||
@@ -439,7 +439,7 @@ pub fn run(args: struct {
|
||||
allocator: mem.Allocator,
|
||||
argv: []const []const u8,
|
||||
cwd: ?[]const u8 = null,
|
||||
cwd_dir: ?fs.Dir = null,
|
||||
cwd_dir: ?Io.Dir = null,
|
||||
/// Required if unable to access the current env map (e.g. building a
|
||||
/// library on some platforms).
|
||||
env_map: ?*const EnvMap = null,
|
||||
|
||||
+31
-29
@@ -1,5 +1,7 @@
|
||||
const std = @import("std.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const std = @import("std.zig");
|
||||
const Io = std.Io;
|
||||
const assert = std.debug.assert;
|
||||
const math = std.math;
|
||||
|
||||
@@ -28,7 +30,7 @@ pub var allocator_instance: std.heap.GeneralPurposeAllocator(.{
|
||||
break :b .init;
|
||||
};
|
||||
|
||||
pub var io_instance: std.Io.Threaded = undefined;
|
||||
pub var io_instance: Io.Threaded = undefined;
|
||||
pub const io = io_instance.io();
|
||||
|
||||
/// TODO https://github.com/ziglang/zig/issues/5738
|
||||
@@ -355,7 +357,7 @@ test expectApproxEqRel {
|
||||
/// This function is intended to be used only in tests. When the two slices are not
|
||||
/// equal, prints diagnostics to stderr to show exactly how they are not equal (with
|
||||
/// the differences highlighted in red), then returns a test failure error.
|
||||
/// The colorized output is optional and controlled by the return of `std.Io.tty.Config.detect`.
|
||||
/// The colorized output is optional and controlled by the return of `Io.tty.Config.detect`.
|
||||
/// If your inputs are UTF-8 encoded strings, consider calling `expectEqualStrings` instead.
|
||||
pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const T) !void {
|
||||
const diff_index: usize = diff_index: {
|
||||
@@ -378,8 +380,8 @@ fn failEqualSlices(
|
||||
expected: []const T,
|
||||
actual: []const T,
|
||||
diff_index: usize,
|
||||
w: *std.Io.Writer,
|
||||
ttyconf: std.Io.tty.Config,
|
||||
w: *Io.Writer,
|
||||
ttyconf: Io.tty.Config,
|
||||
) !void {
|
||||
try w.print("slices differ. first difference occurs at index {d} (0x{X})\n", .{ diff_index, diff_index });
|
||||
|
||||
@@ -464,11 +466,11 @@ fn SliceDiffer(comptime T: type) type {
|
||||
start_index: usize,
|
||||
expected: []const T,
|
||||
actual: []const T,
|
||||
ttyconf: std.Io.tty.Config,
|
||||
ttyconf: Io.tty.Config,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn write(self: Self, writer: *std.Io.Writer) !void {
|
||||
pub fn write(self: Self, writer: *Io.Writer) !void {
|
||||
for (self.expected, 0..) |value, i| {
|
||||
const full_index = self.start_index + i;
|
||||
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 {
|
||||
const BytesDiffer = struct {
|
||||
expected: []const u8,
|
||||
actual: []const u8,
|
||||
ttyconf: std.Io.tty.Config,
|
||||
ttyconf: Io.tty.Config,
|
||||
|
||||
pub fn write(self: BytesDiffer, writer: *std.Io.Writer) !void {
|
||||
pub fn write(self: BytesDiffer, writer: *Io.Writer) !void {
|
||||
var expected_iterator = std.mem.window(u8, self.expected, 16, 16);
|
||||
var row: usize = 0;
|
||||
while (expected_iterator.next()) |chunk| {
|
||||
@@ -535,7 +537,7 @@ const BytesDiffer = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn writeDiff(self: BytesDiffer, writer: *std.Io.Writer, comptime fmt: []const u8, args: anytype, diff: bool) !void {
|
||||
fn writeDiff(self: BytesDiffer, writer: *Io.Writer, comptime fmt: []const u8, args: anytype, diff: bool) !void {
|
||||
if (diff) try self.ttyconf.setColor(writer, .red);
|
||||
try writer.print(fmt, args);
|
||||
if (diff) try self.ttyconf.setColor(writer, .reset);
|
||||
@@ -605,8 +607,8 @@ pub fn expect(ok: bool) !void {
|
||||
}
|
||||
|
||||
pub const TmpDir = struct {
|
||||
dir: std.fs.Dir,
|
||||
parent_dir: std.fs.Dir,
|
||||
dir: Io.Dir,
|
||||
parent_dir: Io.Dir,
|
||||
sub_path: [sub_path_len]u8,
|
||||
|
||||
const random_bytes_count = 12;
|
||||
@@ -620,7 +622,7 @@ pub const TmpDir = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub fn tmpDir(opts: std.fs.Dir.OpenOptions) TmpDir {
|
||||
pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir {
|
||||
var random_bytes: [TmpDir.random_bytes_count]u8 = undefined;
|
||||
std.crypto.random.bytes(&random_bytes);
|
||||
var sub_path: [TmpDir.sub_path_len]u8 = undefined;
|
||||
@@ -929,7 +931,7 @@ test "expectEqualDeep primitive type" {
|
||||
a,
|
||||
b,
|
||||
|
||||
pub fn format(self: @This(), writer: *std.Io.Writer) !void {
|
||||
pub fn format(self: @This(), writer: *Io.Writer) !void {
|
||||
try writer.writeAll(@tagName(self));
|
||||
}
|
||||
};
|
||||
@@ -1160,7 +1162,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
|
||||
} else |err| switch (err) {
|
||||
error.OutOfMemory => {
|
||||
if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) {
|
||||
const tty_config: std.Io.tty.Config = .detect(.stderr());
|
||||
const tty_config: Io.tty.Config = .detect(.stderr());
|
||||
print(
|
||||
"\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {f}",
|
||||
.{
|
||||
@@ -1220,14 +1222,14 @@ pub inline fn fuzz(
|
||||
return @import("root").fuzz(context, testOne, options);
|
||||
}
|
||||
|
||||
/// A `std.Io.Reader` that writes a predetermined list of buffers during `stream`.
|
||||
/// A `Io.Reader` that writes a predetermined list of buffers during `stream`.
|
||||
pub const Reader = struct {
|
||||
calls: []const Call,
|
||||
interface: std.Io.Reader,
|
||||
interface: Io.Reader,
|
||||
next_call_index: usize,
|
||||
next_offset: usize,
|
||||
/// Further reduces how many bytes are written in each `stream` call.
|
||||
artificial_limit: std.Io.Limit = .unlimited,
|
||||
artificial_limit: Io.Limit = .unlimited,
|
||||
|
||||
pub const Call = struct {
|
||||
buffer: []const u8,
|
||||
@@ -1247,7 +1249,7 @@ pub const Reader = struct {
|
||||
};
|
||||
}
|
||||
|
||||
fn stream(io_r: *std.Io.Reader, w: *std.Io.Writer, limit: std.Io.Limit) std.Io.Reader.StreamError!usize {
|
||||
fn stream(io_r: *Io.Reader, w: *Io.Writer, limit: Io.Limit) Io.Reader.StreamError!usize {
|
||||
const r: *Reader = @alignCast(@fieldParentPtr("interface", io_r));
|
||||
if (r.calls.len - r.next_call_index == 0) return error.EndOfStream;
|
||||
const call = r.calls[r.next_call_index];
|
||||
@@ -1262,13 +1264,13 @@ pub const Reader = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// A `std.Io.Reader` that gets its data from another `std.Io.Reader`, and always
|
||||
/// A `Io.Reader` that gets its data from another `Io.Reader`, and always
|
||||
/// writes to its own buffer (and returns 0) during `stream` and `readVec`.
|
||||
pub const ReaderIndirect = struct {
|
||||
in: *std.Io.Reader,
|
||||
interface: std.Io.Reader,
|
||||
in: *Io.Reader,
|
||||
interface: Io.Reader,
|
||||
|
||||
pub fn init(in: *std.Io.Reader, buffer: []u8) ReaderIndirect {
|
||||
pub fn init(in: *Io.Reader, buffer: []u8) ReaderIndirect {
|
||||
return .{
|
||||
.in = in,
|
||||
.interface = .{
|
||||
@@ -1283,17 +1285,17 @@ pub const ReaderIndirect = struct {
|
||||
};
|
||||
}
|
||||
|
||||
fn readVec(r: *std.Io.Reader, _: [][]u8) std.Io.Reader.Error!usize {
|
||||
fn readVec(r: *Io.Reader, _: [][]u8) Io.Reader.Error!usize {
|
||||
try streamInner(r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn stream(r: *std.Io.Reader, _: *std.Io.Writer, _: std.Io.Limit) std.Io.Reader.StreamError!usize {
|
||||
fn stream(r: *Io.Reader, _: *Io.Writer, _: Io.Limit) Io.Reader.StreamError!usize {
|
||||
try streamInner(r);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn streamInner(r: *std.Io.Reader) std.Io.Reader.Error!void {
|
||||
fn streamInner(r: *Io.Reader) Io.Reader.Error!void {
|
||||
const r_indirect: *ReaderIndirect = @alignCast(@fieldParentPtr("interface", r));
|
||||
|
||||
// If there's no room remaining in the buffer at all, make room.
|
||||
@@ -1301,12 +1303,12 @@ pub const ReaderIndirect = struct {
|
||||
try r.rebase(r.buffer.len);
|
||||
}
|
||||
|
||||
var writer: std.Io.Writer = .{
|
||||
var writer: Io.Writer = .{
|
||||
.buffer = r.buffer,
|
||||
.end = r.end,
|
||||
.vtable = &.{
|
||||
.drain = std.Io.Writer.unreachableDrain,
|
||||
.rebase = std.Io.Writer.unreachableRebase,
|
||||
.drain = Io.Writer.unreachableDrain,
|
||||
.rebase = Io.Writer.unreachableRebase,
|
||||
},
|
||||
};
|
||||
defer r.end = writer.end;
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn free(sdk: WindowsSdk, allocator: Allocator) void {
|
||||
/// and a version. Returns slice of version strings sorted in descending order.
|
||||
/// Caller owns result.
|
||||
fn iterateAndFilterByVersion(
|
||||
iterator: *std.fs.Dir.Iterator,
|
||||
iterator: *Io.Dir.Iterator,
|
||||
allocator: Allocator,
|
||||
prefix: []const u8,
|
||||
) error{OutOfMemory}![][]const u8 {
|
||||
@@ -608,7 +608,7 @@ pub const Installation = struct {
|
||||
};
|
||||
|
||||
const MsvcLibDir = struct {
|
||||
fn findInstancesDirViaSetup(allocator: Allocator) error{ OutOfMemory, PathNotFound }!std.fs.Dir {
|
||||
fn findInstancesDirViaSetup(allocator: Allocator) error{ OutOfMemory, PathNotFound }!Io.Dir {
|
||||
const vs_setup_key_path = "SOFTWARE\\Microsoft\\VisualStudio\\Setup";
|
||||
const vs_setup_key = RegistryWtf8.openKey(windows.HKEY_LOCAL_MACHINE, vs_setup_key_path, .{}) catch |err| switch (err) {
|
||||
error.KeyNotFound => return error.PathNotFound,
|
||||
@@ -633,7 +633,7 @@ const MsvcLibDir = struct {
|
||||
return std.fs.openDirAbsolute(instances_path, .{ .iterate = true }) catch return error.PathNotFound;
|
||||
}
|
||||
|
||||
fn findInstancesDirViaCLSID(allocator: Allocator) error{ OutOfMemory, PathNotFound }!std.fs.Dir {
|
||||
fn findInstancesDirViaCLSID(allocator: Allocator) error{ OutOfMemory, PathNotFound }!Io.Dir {
|
||||
const setup_configuration_clsid = "{177f0c4a-1cd3-4de7-a32c-71dbbb9fa36d}";
|
||||
const setup_config_key = RegistryWtf8.openKey(windows.HKEY_CLASSES_ROOT, "CLSID\\" ++ setup_configuration_clsid, .{}) catch |err| switch (err) {
|
||||
error.KeyNotFound => return error.PathNotFound,
|
||||
@@ -669,7 +669,7 @@ const MsvcLibDir = struct {
|
||||
return std.fs.openDirAbsolute(instances_path, .{ .iterate = true }) catch return error.PathNotFound;
|
||||
}
|
||||
|
||||
fn findInstancesDir(allocator: Allocator) error{ OutOfMemory, PathNotFound }!std.fs.Dir {
|
||||
fn findInstancesDir(allocator: Allocator) error{ OutOfMemory, PathNotFound }!Io.Dir {
|
||||
// First, try getting the packages cache path from the registry.
|
||||
// This only seems to exist when the path is different from the default.
|
||||
method1: {
|
||||
|
||||
@@ -9582,7 +9582,7 @@ pub fn dump(b: *Builder) void {
|
||||
b.printToFile(stderr, &buffer) catch {};
|
||||
}
|
||||
|
||||
pub fn printToFilePath(b: *Builder, io: Io, dir: std.fs.Dir, path: []const u8) !void {
|
||||
pub fn printToFilePath(b: *Builder, io: Io, dir: Io.Dir, path: []const u8) !void {
|
||||
var buffer: [4000]u8 = undefined;
|
||||
const file = try dir.createFile(io, path, .{});
|
||||
defer file.close(io);
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ const builtin = @import("builtin");
|
||||
const is_le = builtin.target.cpu.arch.endian() == .little;
|
||||
|
||||
const std = @import("std");
|
||||
const Io = std.Io;
|
||||
const File = std.Io.File;
|
||||
const Writer = std.Io.Writer;
|
||||
const Reader = std.Io.Reader;
|
||||
@@ -461,7 +462,7 @@ pub const Iterator = struct {
|
||||
stream: *File.Reader,
|
||||
options: ExtractOptions,
|
||||
filename_buf: []u8,
|
||||
dest: std.fs.Dir,
|
||||
dest: Io.Dir,
|
||||
) !void {
|
||||
if (filename_buf.len < self.filename_len)
|
||||
return error.ZipInsufficientBuffer;
|
||||
@@ -650,7 +651,7 @@ pub const ExtractOptions = struct {
|
||||
};
|
||||
|
||||
/// Extract the zipped files to the given `dest` directory.
|
||||
pub fn extract(dest: std.fs.Dir, fr: *File.Reader, options: ExtractOptions) !void {
|
||||
pub fn extract(dest: Io.Dir, fr: *File.Reader, options: ExtractOptions) !void {
|
||||
if (options.verify_checksums) @panic("TODO unimplemented");
|
||||
|
||||
var iter = try Iterator.init(fr);
|
||||
|
||||
+2
-2
@@ -446,7 +446,7 @@ pub const Path = struct {
|
||||
}
|
||||
|
||||
/// Given a `Path`, returns the directory handle and sub path to be used to open the path.
|
||||
pub fn openInfo(p: Path, dirs: Directories) struct { fs.Dir, []const u8 } {
|
||||
pub fn openInfo(p: Path, dirs: Directories) struct { Io.Dir, []const u8 } {
|
||||
const dir = switch (p.root) {
|
||||
.none => {
|
||||
const cwd_sub_path = absToCwdRelative(p.sub_path, dirs.cwd);
|
||||
@@ -1872,7 +1872,7 @@ pub const CreateDiagnostic = union(enum) {
|
||||
pub const CreateCachePath = struct {
|
||||
which: enum { local, global },
|
||||
sub: []const u8,
|
||||
err: (fs.Dir.MakeError || fs.Dir.OpenError || fs.Dir.StatFileError),
|
||||
err: (Io.Dir.MakeError || Io.Dir.OpenError || Io.Dir.StatFileError),
|
||||
};
|
||||
pub fn format(diag: CreateDiagnostic, w: *Writer) Writer.Error!void {
|
||||
switch (diag) {
|
||||
|
||||
@@ -214,7 +214,7 @@ pub const Repository = struct {
|
||||
pub fn checkout(
|
||||
repository: *Repository,
|
||||
io: Io,
|
||||
worktree: std.fs.Dir,
|
||||
worktree: Io.Dir,
|
||||
commit_oid: Oid,
|
||||
diagnostics: *Diagnostics,
|
||||
) !void {
|
||||
@@ -231,7 +231,7 @@ pub const Repository = struct {
|
||||
fn checkoutTree(
|
||||
repository: *Repository,
|
||||
io: Io,
|
||||
dir: std.fs.Dir,
|
||||
dir: Io.Dir,
|
||||
tree_oid: Oid,
|
||||
current_path: []const u8,
|
||||
diagnostics: *Diagnostics,
|
||||
|
||||
+3
-3
@@ -204,7 +204,7 @@ pub fn run(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8) !
|
||||
}
|
||||
}
|
||||
|
||||
fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) !void {
|
||||
fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: Io.Dir, sub_path: []const u8) !void {
|
||||
fmtPathFile(fmt, file_path, check_mode, dir, sub_path) catch |err| switch (err) {
|
||||
error.IsDir, error.AccessDenied => return fmtPathDir(fmt, file_path, check_mode, dir, sub_path),
|
||||
else => {
|
||||
@@ -219,7 +219,7 @@ fn fmtPathDir(
|
||||
fmt: *Fmt,
|
||||
file_path: []const u8,
|
||||
check_mode: bool,
|
||||
parent_dir: fs.Dir,
|
||||
parent_dir: Io.Dir,
|
||||
parent_sub_path: []const u8,
|
||||
) !void {
|
||||
const io = fmt.io;
|
||||
@@ -257,7 +257,7 @@ fn fmtPathFile(
|
||||
fmt: *Fmt,
|
||||
file_path: []const u8,
|
||||
check_mode: bool,
|
||||
dir: fs.Dir,
|
||||
dir: Io.Dir,
|
||||
sub_path: []const u8,
|
||||
) !void {
|
||||
const io = fmt.io;
|
||||
|
||||
+4
-3
@@ -400,7 +400,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void {
|
||||
// regarding eliding redundant object -> object transformations.
|
||||
return error.NoObjectsToLink;
|
||||
};
|
||||
try std.fs.Dir.copyFile(
|
||||
try Io.Dir.copyFile(
|
||||
the_object_path.root_dir.handle,
|
||||
the_object_path.sub_path,
|
||||
directory.handle,
|
||||
@@ -816,7 +816,7 @@ fn elfLink(lld: *Lld, arena: Allocator) !void {
|
||||
// regarding eliding redundant object -> object transformations.
|
||||
return error.NoObjectsToLink;
|
||||
};
|
||||
try std.fs.Dir.copyFile(
|
||||
try Io.Dir.copyFile(
|
||||
the_object_path.root_dir.handle,
|
||||
the_object_path.sub_path,
|
||||
directory.handle,
|
||||
@@ -1371,7 +1371,7 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void {
|
||||
// regarding eliding redundant object -> object transformations.
|
||||
return error.NoObjectsToLink;
|
||||
};
|
||||
try fs.Dir.copyFile(
|
||||
try Io.Dir.copyFile(
|
||||
the_object_path.root_dir.handle,
|
||||
the_object_path.sub_path,
|
||||
directory.handle,
|
||||
@@ -1692,6 +1692,7 @@ fn spawnLld(comp: *Compilation, arena: Allocator, argv: []const []const u8) !voi
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const Io = std.Io;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Cache = std.Build.Cache;
|
||||
const allocPrint = std.fmt.allocPrint;
|
||||
|
||||
+1
-1
@@ -3573,7 +3573,7 @@ pub fn getTarget(self: *const MachO) *const std.Target {
|
||||
/// into a new inode, remove the original file, and rename the copy to match
|
||||
/// the original file. This is super messy, but there doesn't seem any other
|
||||
/// way to please the XNU.
|
||||
pub fn invalidateKernelCache(dir: fs.Dir, sub_path: []const u8) !void {
|
||||
pub fn invalidateKernelCache(dir: Io.Dir, sub_path: []const u8) !void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
if (builtin.target.os.tag.isDarwin() and builtin.target.cpu.arch == .aarch64) {
|
||||
|
||||
Reference in New Issue
Block a user