zig: show list of files in a directory
A usage of list files, is building existed C libraries, listing all C files is annoying.
var general = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = general.deinit(); const dir = "./src/"; var sources = std.fs.Dir.Iterator{ .dir = try std.fs.cwd().openDir(dir, .{}), .seek = 0, .buf = [_]u8{0} ** 8192, .index = 0, .end_index = 0, }; var src = try sources.next(); while (src != null) : (src = try sources.next()) { const file = try std.mem.concat(general.allocator(), u8, &[_][]const u8{ dir, src.?.name, }); lib.addCSourceFile(file, &flags); }