authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 11:49:46 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 11:49:46 -07:00
loga2daf4349057395345f7386b69f6ae3a636148d6
tree2cd8d1f9f3368803f2bd7a821cc219c50931c6fb
parentfb1a2c10d11ff10d715312ff961e3e7d9ce1d563

util: file_list: use extras.fileList


1 files changed, 3 insertions(+), 17 deletions(-)

src/util/funcs.zig+3-17
......@@ -76,23 +76,9 @@ pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool
7676}
7777
7878pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string {
79 var list = std.ArrayList(string).init(alloc);
80 defer list.deinit();
81
82 const dir = try std.fs.cwd().openIterableDir(dpath, .{});
83 var walk = try dir.walk(alloc);
84 defer walk.deinit();
85 while (true) {
86 if (try walk.next()) |entry| {
87 if (entry.kind != .File) {
88 continue;
89 }
90 try list.append(try alloc.dupe(u8, entry.path));
91 } else {
92 break;
93 }
94 }
95 return list.toOwnedSlice();
79 var dir = try std.fs.cwd().openIterableDir(dpath, .{});
80 defer dir.close();
81 return try extras.fileList(alloc, dir);
9682}
9783
9884pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.ChildProcess.ExecResult {