refactor(ascii): use utils.readFile to read the ascii art file
This commit is contained in:
@@ -72,14 +72,10 @@ pub fn printAsciiAndModules(allocator: std.mem.Allocator, ascii_art_path: ?[]u8,
|
||||
|
||||
var ascii_art_data: []const u8 = undefined;
|
||||
if (ascii_art_path) |ascii| {
|
||||
var ascii_file = try std.fs.cwd().openFile(ascii, .{});
|
||||
const ascii_file = try std.fs.cwd().openFile(ascii, .{});
|
||||
defer ascii_file.close();
|
||||
const file_size = (try ascii_file.stat()).size;
|
||||
|
||||
var file_buf = try allocator.alloc(u8, file_size);
|
||||
var reader = std.fs.File.Reader.init(ascii_file, file_buf);
|
||||
const read = try reader.read(file_buf);
|
||||
ascii_art_data = file_buf[0..read];
|
||||
ascii_art_data = try utils.readFile(allocator, ascii_file, file_size);
|
||||
} else {
|
||||
ascii_art_data = @embedFile("./assets/ascii/guy_fawks.txt");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user