From a2daf4349057395345f7386b69f6ae3a636148d6 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 18 Sep 2022 11:49:46 -0700 Subject: [PATCH] util: file_list: use extras.fileList --- src/util/funcs.zig | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 26a7ef9e298dd70c485ee2a32fc8ae8016c7f5f7..88d90e80903aad49af45d75e53284fa9e60c9a06 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -76,23 +76,9 @@ pub fn list_contains_gen(comptime T: type, haystack: []const T, needle: T) bool } pub fn file_list(alloc: std.mem.Allocator, dpath: string) ![]const string { - var list = std.ArrayList(string).init(alloc); - defer list.deinit(); - - const dir = try std.fs.cwd().openIterableDir(dpath, .{}); - var walk = try dir.walk(alloc); - defer walk.deinit(); - while (true) { - if (try walk.next()) |entry| { - if (entry.kind != .File) { - continue; - } - try list.append(try alloc.dupe(u8, entry.path)); - } else { - break; - } - } - return list.toOwnedSlice(); + var dir = try std.fs.cwd().openIterableDir(dpath, .{}); + defer dir.close(); + return try extras.fileList(alloc, dir); } pub fn run_cmd_raw(alloc: std.mem.Allocator, dir: ?string, args: []const string) !std.ChildProcess.ExecResult { -- 2.54.0