aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Kupty <hkupty@gmail.com>2025-09-25 22:22:08 +0200
committerRyan Liptak <squeek502@hotmail.com>2025-10-03 16:29:08 -0700
commitec4514def41db988f89c2da180f7a8f87168f5d1 (patch)
treebc6c06acdc77593175fde4e94a502b5a25e4496b
parentdf394faf776aa7012649dc1724ccb66d78a1439e (diff)
downloadzig-ec4514def41db988f89c2da180f7a8f87168f5d1.tar.gz
zig-ec4514def41db988f89c2da180f7a8f87168f5d1.zip
refactor: Reimplement tool using SelectiveWalker
This skips directory trees where top-level directories do not match the defined ones
-rw-r--r--tools/update_mingw.zig28
1 files changed, 20 insertions, 8 deletions
diff --git a/tools/update_mingw.zig b/tools/update_mingw.zig
index 9c67b27375..3f82093681 100644
--- a/tools/update_mingw.zig
+++ b/tools/update_mingw.zig
@@ -109,13 +109,31 @@ pub fn main() !void {
{
// Also add all new def and def.in files.
- var walker = try src_crt_dir.walk(arena);
+ var walker = try src_crt_dir.walkSelectively(arena);
defer walker.deinit();
var fail = false;
while (try walker.next()) |entry| {
- if (entry.kind != .file) continue;
+ switch (entry.kind) {
+ .directory => {
+ switch (walker.depth()) {
+ 1 => for (def_dirs) |p| {
+ if (std.mem.eql(u8, entry.basename, p)) {
+ try walker.enter(entry);
+ continue;
+ }
+ },
+ else => {
+ // The top-level directory was already validated
+ try walker.enter(entry);
+ continue;
+ },
+ }
+ },
+ .file => {},
+ else => continue,
+ }
const ok_ext = for (def_exts) |ext| {
if (std.mem.endsWith(u8, entry.path, ext)) break true;
@@ -123,12 +141,6 @@ pub fn main() !void {
if (!ok_ext) continue;
- const ok_prefix = for (def_dirs) |p| {
- if (std.mem.startsWith(u8, entry.path, p)) break true;
- } else false;
-
- if (!ok_prefix) continue;
-
const blacklisted = for (blacklisted_defs) |item| {
if (std.mem.eql(u8, entry.basename, item)) break true;
} else false;