chiui-li/zig-read-file
No description provided.
zig fetch --save "git+https://github.com/chiui-li/zig-read-file.git#v1.0.0"
Then, in your build.zig's build function, add the following before b.installArtifact(exe):
const read_file = b.dependency("read_file", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("read_file", read_file.module("read_file"));
const read_file = @import("read_file");
const content = try read_file.read(std.heap.page_allocator, "/path/to/your/file");
// or use relative path
// read_file.read(std.heap.page_allocator, "./to/your/file");
defer std.heap.page_allocator.free(content);