do not skip symlinks
add filter option
add usage example for files array to README
A small Zig library for embedding directory trees with @embedFile
.
Generates a Zig source file that you can import into your code.
In build.zig
:
const embed_dir = @import("embed-dir/lib.zig");
pub fn build(b: *Builder) !void {
// …
try embed_dir.writeZig(std.heap.page_allocator, .{
.target = "src/embed.zig", // default
.dir = "www",
});
}
Your code:
const embed = @import("embed.zig");
pub fn main() !void {
const index = embed.get("index.html").?;
// or allocate a HashMap:
const map = embed.initMap(std.heap.page_allocator);
defer map.deinit();
const index = map.getValue("index.html").?;
// array of embedded files:
for (embed.files) |file| std.debug.warn("{}\n", .{file});
}