buf: [4096]u8, w: std.Io.File.Writer, file: std.Io.File, dir: std.Io.Dir, io: std.Io, pub fn opencwd(self: *@This(), io: std.Io, path: []const u8) !void { try self.open(io, std.Io.Dir.cwd(), path); } pub fn open(self: *@This(), io: std.Io, dir: std.Io.Dir, path: []const u8) !void { self.dir = dir; self.file = try dir.openFile(io, path, .{}); self.io = io; self.w = self.file.writer(self.io, &self.buf); } pub fn createcwd(self: *@This(), io: std.Io, path: []const u8) !void { try self.create(io, std.Io.Dir.cwd(), path); } pub fn create(self: *@This(), io: std.Io, dir: std.Io.Dir, path: []const u8) !void { self.dir = dir; self.io = io; self.file = try dir.createFile(io, path, .{}); self.w = self.file.writer(self.io, &self.buf); } pub fn close(self: *@This()) void { self.w.flush() catch {}; self.file.close(self.io); } pub fn writer(self: *@This()) *std.Io.Writer { return &self.w.interface; } const std = @import("std");