authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-21 16:13:31 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-21 16:13:31 -08:00
log266730c68904083e0b94edb86a925587b4339600
tree4abf53fc54fc746a8060903039297f33f608e6f5
parente6ccf23520fb89e56a8a6c1a9c93b07d5177bba5

add util.file_list


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

src/util/funcs.zig+15
......@@ -130,3 +130,18 @@ pub fn list_contains_gen(comptime T: type, haystack: *std.ArrayList(T), needle:
130130 }
131131 return false;
132132}
133
134pub fn file_list(dpath: []const u8, list: *std.ArrayList([]const u8)) !void {
135 var walk = try std.fs.walkPath(gpa, dpath);
136 while (true) {
137 if (try walk.next()) |entry| {
138 if (entry.kind != .File) {
139 continue;
140 }
141 try list.append(try gpa.dupe(u8, entry.path));
142 }
143 else {
144 break;
145 }
146 }
147}