authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-11-18 21:19:03 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-11-18 21:19:03 -08:00
logc8d6aa1b697e6f704ac1a12fc6859055231f3449
tree82dbed1623164f08258b46f43c92c22a172620ac
parent890ea2b35ad9df88f52e01c7839f30b9bb54a0d9

add fileList


1 files changed, 15 insertions(+), 0 deletions(-)

src/lib.zig+15
......@@ -109,3 +109,18 @@ pub fn FieldType(comptime T: type, comptime field: std.meta.FieldEnum(T)) type {
109109 }
110110 unreachable;
111111}
112
113pub fn fileList(alloc: *std.mem.Allocator, dir: std.fs.Dir) ![]string {
114 var list = std.ArrayList(string).init(alloc);
115 defer list.deinit();
116
117 var walk = try dir.walk(alloc);
118 defer walk.deinit();
119 while (try walk.next()) |entry| {
120 if (entry.kind != .File) {
121 continue;
122 }
123 try list.append(try alloc.dupe(u8, entry.path));
124 }
125 return list.toOwnedSlice();
126}