diff --git a/src/scan.zig b/src/scan.zig index 209c9e9..03dfdf6 100644 --- a/src/scan.zig +++ b/src/scan.zig @@ -13,9 +13,9 @@ const c = @import("c.zig").c; // This function only works on Linux -fn isKernfs(dir: std.fs.Dir) bool { +fn isKernfs(dir: std.Io.Dir) bool { var buf: c.struct_statfs = undefined; - if (c.fstatfs(dir.fd, &buf) != 0) return false; // silently ignoring errors isn't too nice. + if (c.fstatfs(dir.handle, &buf) != 0) return false; // silently ignoring errors isn't too nice. const iskern = switch (util.castTruncate(u32, buf.f_type)) { // These numbers are documented in the Linux 'statfs(2)' man page, so I assume they're stable. 0x42494e4d, // BINFMTFS_MAGIC @@ -142,9 +142,9 @@ pub fn statAt(parent: std.Io.Dir, name: [:0]const u8, follow: bool, symlink: ?*b } -fn isCacheDir(dir: std.fs.Dir) bool { +fn isCacheDir(dir: std.Io.Dir) bool { const sig = "Signature: 8a477f597d28d172789f06886806bc55"; - const f = dir.openFileZ("CACHEDIR.TAG", .{}) catch return false; + const f = dir.openFile(main.io, "CACHEDIR.TAG", .{}) catch return false; defer f.close(); var buf: [sig.len]u8 = undefined; const len = f.readAll(&buf) catch return false; @@ -210,13 +210,13 @@ const State = struct { const Dir = struct { - fd: std.fs.Dir, + fd: std.Io.Dir, dev: u64, pat: exclude.Patterns, - it: std.fs.Dir.Iterator, + it: std.Io.Dir.Iterator, sink: *sink.Dir, - fn create(fd: std.fs.Dir, dev: u64, pat: exclude.Patterns, s: *sink.Dir) *Dir { + fn create(fd: std.Io.Dir, dev: u64, pat: exclude.Patterns, s: *sink.Dir) *Dir { const d = main.allocator.create(Dir) catch unreachable; d.* = .{ .fd = fd, @@ -230,7 +230,7 @@ const Dir = struct { fn destroy(d: *Dir, t: *Thread) void { d.pat.deinit(); - d.fd.close(); + d.fd.close(main.io); d.sink.unref(t.sink); main.allocator.destroy(d); } @@ -295,7 +295,7 @@ const Thread = struct { return; } - var edir = dir.fd.openDirZ(name, .{ .no_follow = true, .iterate = true }) catch { + var edir = dir.fd.openDir(main.io, name, .{ .follow_symlinks = false, .iterate = true }) catch { const s = dir.sink.addDir(t.sink, name, &stat); s.setReadError(t.sink); s.unref(t.sink); @@ -307,14 +307,14 @@ const Thread = struct { and stat.dev != dir.dev and isKernfs(edir) ) { - edir.close(); + edir.close(main.io); dir.sink.addSpecial(t.sink, name, .kernfs); return; } if (main.config.exclude_caches and isCacheDir(edir)) { dir.sink.addSpecial(t.sink, name, .pattern); - edir.close(); + edir.close(main.io); return; } @@ -335,7 +335,7 @@ const Thread = struct { t.sink.setDir(d.sink); if (t.thread_num == 0) main.handleEvent(false, false); - const entry = d.it.next() catch blk: { + const entry = d.it.next(main.io) catch blk: { dir.sink.setReadError(t.sink); break :blk null; };