mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
src: update to stdlib changes in Zig 0.12.0-dev.1710+2bffd8101
* std.fs.Dir/IterableDir separation was reverted in https://www.github.com/ziglang/zig/pull/18076 , fix breaks ability to compile with Zig 0.11.0. It was planned since at least October, 16th: https://github.com/ziglang/zig/pull/12060#issuecomment-1763671541 . Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
This commit is contained in:
parent
491988d9a5
commit
f03eee5443
2 changed files with 9 additions and 11 deletions
|
|
@ -45,7 +45,7 @@ fn deleteItem(dir: std.fs.Dir, path: [:0]const u8, ptr: *align(1) ?*model.Entry)
|
|||
return true;
|
||||
|
||||
if (entry.dir()) |d| {
|
||||
var fd = dir.openDirZ(path, .{.no_follow = true}, false) catch |e| return err(e);
|
||||
var fd = dir.openDirZ(path, .{ .no_follow = true, .iterate = false }) catch |e| return err(e);
|
||||
var it = &d.sub;
|
||||
parent = d;
|
||||
defer parent = parent.parent.?;
|
||||
|
|
|
|||
18
src/scan.zig
18
src/scan.zig
|
|
@ -454,8 +454,8 @@ const Context = struct {
|
|||
var active_context: *Context = undefined;
|
||||
|
||||
// Read and index entries of the given dir.
|
||||
fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.IterableDir, dir_dev: u64) void {
|
||||
var it = main.allocator.create(std.fs.IterableDir.Iterator) catch unreachable;
|
||||
fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.Dir, dir_dev: u64) void {
|
||||
var it = main.allocator.create(std.fs.Dir.Iterator) catch unreachable;
|
||||
defer main.allocator.destroy(it);
|
||||
it.* = dir.iterate();
|
||||
while(true) {
|
||||
|
|
@ -475,7 +475,7 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.IterableDir,
|
|||
continue;
|
||||
}
|
||||
|
||||
ctx.stat = Stat.read(dir.dir, ctx.name, false) catch {
|
||||
ctx.stat = Stat.read(dir, ctx.name, false) catch {
|
||||
ctx.addSpecial(.err);
|
||||
continue;
|
||||
};
|
||||
|
|
@ -485,7 +485,7 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.IterableDir,
|
|||
}
|
||||
|
||||
if (main.config.follow_symlinks and ctx.stat.symlink) {
|
||||
if (Stat.read(dir.dir, ctx.name, true)) |nstat| {
|
||||
if (Stat.read(dir, ctx.name, true)) |nstat| {
|
||||
if (!nstat.dir) {
|
||||
ctx.stat = nstat;
|
||||
// Symlink targets may reside on different filesystems,
|
||||
|
|
@ -502,20 +502,19 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.IterableDir,
|
|||
|
||||
var edir =
|
||||
if (!ctx.stat.dir) null
|
||||
else if (dir.dir.openDirZ(ctx.name, .{ .no_follow = true }, true)) |d| std.fs.IterableDir{.dir = d}
|
||||
else |_| {
|
||||
else dir.openDirZ(ctx.name, .{ .no_follow = true, .iterate = true }) catch {
|
||||
ctx.addSpecial(.err);
|
||||
continue;
|
||||
};
|
||||
defer if (edir != null) edir.?.close();
|
||||
|
||||
if (@import("builtin").os.tag == .linux and main.config.exclude_kernfs and ctx.stat.dir and isKernfs(edir.?.dir, ctx.stat.dev)) {
|
||||
if (@import("builtin").os.tag == .linux and main.config.exclude_kernfs and ctx.stat.dir and isKernfs(edir.?, ctx.stat.dev)) {
|
||||
ctx.addSpecial(.kernfs);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (main.config.exclude_caches and ctx.stat.dir) {
|
||||
if (edir.?.dir.openFileZ("CACHEDIR.TAG", .{})) |f| {
|
||||
if (edir.?.openFileZ("CACHEDIR.TAG", .{})) |f| {
|
||||
const sig = "Signature: 8a477f597d28d172789f06886806bc55";
|
||||
var buf: [sig.len]u8 = undefined;
|
||||
if (f.reader().readAll(&buf)) |len| {
|
||||
|
|
@ -562,14 +561,13 @@ pub fn setupRefresh(parent: *model.Dir) void {
|
|||
// To be called after setupRefresh() (or from scanRoot())
|
||||
pub fn scan() void {
|
||||
defer active_context.deinit();
|
||||
const dir_ = std.fs.cwd().openDirZ(active_context.pathZ(), .{}, true) catch |e| {
|
||||
var dir = std.fs.cwd().openDirZ(active_context.pathZ(), .{ .iterate = true }) catch |e| {
|
||||
active_context.last_error = main.allocator.dupeZ(u8, active_context.path.items) catch unreachable;
|
||||
active_context.fatal_error = e;
|
||||
while (main.state == .refresh or main.state == .scan)
|
||||
main.handleEvent(true, true);
|
||||
return;
|
||||
};
|
||||
var dir = std.fs.IterableDir{.dir = dir_};
|
||||
defer dir.close();
|
||||
var pat = exclude.getPatterns(active_context.pathZ());
|
||||
defer pat.deinit();
|
||||
|
|
|
|||
Loading…
Reference in a new issue