refactor(ascii): use new Io
This commit is contained in:
@@ -65,17 +65,17 @@ test "parse ffffff" {
|
|||||||
try std.testing.expect((result.r == 255) and (result.g == 255) and (result.b == 255));
|
try std.testing.expect((result.r == 255) and (result.g == 255) and (result.b == 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn printAsciiAndModules(allocator: std.mem.Allocator, ascii_art_path: ?[]u8, sys_info_list: std.array_list.Managed([]u8)) !void {
|
pub fn printAsciiAndModules(allocator: std.mem.Allocator, io: std.Io, ascii_art_path: ?[]u8, sys_info_list: std.array_list.Managed([]u8)) !void {
|
||||||
var stdout_buffer: [2048]u8 = undefined;
|
var stdout_buffer: [2048]u8 = undefined;
|
||||||
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
|
var stdout_file_writer: std.Io.File.Writer = .init(.stdout(), io, &stdout_buffer);
|
||||||
const stdout = &stdout_writer.interface;
|
const stdout = &stdout_file_writer.interface;
|
||||||
|
|
||||||
var ascii_art_data: []const u8 = undefined;
|
var ascii_art_data: []const u8 = undefined;
|
||||||
if (ascii_art_path) |ascii| {
|
if (ascii_art_path) |ascii| {
|
||||||
const ascii_file = try std.fs.cwd().openFile(ascii, .{ .mode = .read_only });
|
const ascii_file = try std.Io.Dir.cwd().openFile(io, ascii, .{ .mode = .read_only });
|
||||||
defer ascii_file.close();
|
defer ascii_file.close(io);
|
||||||
const file_size = (try ascii_file.stat()).size;
|
const file_size = (try ascii_file.stat(io)).size;
|
||||||
ascii_art_data = try utils.readFile(allocator, ascii_file, file_size);
|
ascii_art_data = try utils.readFile(allocator, io, ascii_file, file_size);
|
||||||
} else {
|
} else {
|
||||||
ascii_art_data = @embedFile("./assets/ascii/guy_fawks.txt");
|
ascii_art_data = @embedFile("./assets/ascii/guy_fawks.txt");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user