update to Zig std library 0.10.0

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
Eric Joldasov 2022-08-22 02:08:37 +06:00
parent d523a77fdc
commit 3b4b88ab2a
No known key found for this signature in database
GPG key ID: 5C9C69060686B588
3 changed files with 11 additions and 12 deletions

View file

@ -45,7 +45,7 @@ fn deleteItem(dir: std.fs.Dir, path: [:0]const u8, ptr: *align(1) ?*model.Entry)
return true; return true;
if (entry.dir()) |d| { if (entry.dir()) |d| {
var fd = dir.openDirZ(path, .{ .access_sub_paths = true, .iterate = false }) var fd = dir.openDirZ(path, .{ .access_sub_paths = true }, false)
catch |e| return err(e); catch |e| return err(e);
var it = &d.sub; var it = &d.sub;
parent = d; parent = d;

View file

@ -343,8 +343,7 @@ fn spawnShell() void {
env.put("NCDU_LEVEL", "1") catch unreachable; env.put("NCDU_LEVEL", "1") catch unreachable;
const shell = std.os.getenvZ("NCDU_SHELL") orelse std.os.getenvZ("SHELL") orelse "/bin/sh"; const shell = std.os.getenvZ("NCDU_SHELL") orelse std.os.getenvZ("SHELL") orelse "/bin/sh";
var child = std.ChildProcess.init(&.{shell}, allocator) catch unreachable; var child = std.ChildProcess.init(&.{shell}, allocator);
defer child.deinit();
child.cwd = path.items; child.cwd = path.items;
child.env_map = &env; child.env_map = &env;

View file

@ -450,10 +450,10 @@ const Context = struct {
var active_context: *Context = undefined; var active_context: *Context = undefined;
// Read and index entries of the given dir. // Read and index entries of the given dir.
fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.Dir, dir_dev: u64) void { fn scanDir(ctx: *Context, pat: *const exclude.Patterns, iterable_dir: std.fs.IterableDir, dir_dev: u64) void {
var it = main.allocator.create(std.fs.Dir.Iterator) catch unreachable; var it = main.allocator.create(std.fs.IterableDir.Iterator) catch unreachable;
defer main.allocator.destroy(it); defer main.allocator.destroy(it);
it.* = dir.iterate(); it.* = iterable_dir.iterate();
while(true) { while(true) {
const entry = it.next() catch { const entry = it.next() catch {
ctx.setDirlistError(); ctx.setDirlistError();
@ -471,7 +471,7 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.Dir, dir_dev
continue; continue;
} }
ctx.stat = Stat.read(dir, ctx.name, false) catch { ctx.stat = Stat.read(iterable_dir.dir, ctx.name, false) catch {
ctx.addSpecial(.err); ctx.addSpecial(.err);
continue; continue;
}; };
@ -481,7 +481,7 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.Dir, dir_dev
} }
if (main.config.follow_symlinks and ctx.stat.symlink) { if (main.config.follow_symlinks and ctx.stat.symlink) {
if (Stat.read(dir, ctx.name, true)) |nstat| { if (Stat.read(iterable_dir.dir, ctx.name, true)) |nstat| {
if (!nstat.dir) { if (!nstat.dir) {
ctx.stat = nstat; ctx.stat = nstat;
// Symlink targets may reside on different filesystems, // Symlink targets may reside on different filesystems,
@ -497,19 +497,19 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.Dir, dir_dev
}; };
var edir = var edir =
if (ctx.stat.dir) dir.openDirZ(ctx.name, .{ .access_sub_paths = true, .iterate = true, .no_follow = true }) catch { if (ctx.stat.dir) iterable_dir.dir.openIterableDir(ctx.name, .{ .access_sub_paths = true, .no_follow = true }) catch {
ctx.addSpecial(.err); ctx.addSpecial(.err);
continue; continue;
} else null; } else null;
defer if (edir != null) edir.?.close(); defer if (edir != null) edir.?.close();
if (@import("builtin").os.tag == .linux and main.config.exclude_kernfs and ctx.stat.dir and isKernfs(edir.?, ctx.stat.dev)) { if (@import("builtin").os.tag == .linux and main.config.exclude_kernfs and ctx.stat.dir and isKernfs(edir.?.dir, ctx.stat.dev)) {
ctx.addSpecial(.kernfs); ctx.addSpecial(.kernfs);
continue; continue;
} }
if (main.config.exclude_caches and ctx.stat.dir) { if (main.config.exclude_caches and ctx.stat.dir) {
if (edir.?.openFileZ("CACHEDIR.TAG", .{})) |f| { if (edir.?.dir.openFileZ("CACHEDIR.TAG", .{})) |f| {
const sig = "Signature: 8a477f597d28d172789f06886806bc55"; const sig = "Signature: 8a477f597d28d172789f06886806bc55";
var buf: [sig.len]u8 = undefined; var buf: [sig.len]u8 = undefined;
if (f.reader().readAll(&buf)) |len| { if (f.reader().readAll(&buf)) |len| {
@ -556,7 +556,7 @@ pub fn setupRefresh(parent: *model.Dir) void {
// To be called after setupRefresh() (or from scanRoot()) // To be called after setupRefresh() (or from scanRoot())
pub fn scan() void { pub fn scan() void {
defer active_context.deinit(); defer active_context.deinit();
var dir = std.fs.cwd().openDirZ(active_context.pathZ(), .{ .access_sub_paths = true, .iterate = true }) catch |e| { var dir = std.fs.cwd().openIterableDir(active_context.pathZ(), .{ .access_sub_paths = true }) catch |e| {
active_context.last_error = main.allocator.dupeZ(u8, active_context.path.items) catch unreachable; active_context.last_error = main.allocator.dupeZ(u8, active_context.path.items) catch unreachable;
active_context.fatal_error = e; active_context.fatal_error = e;
while (main.state == .refresh or main.state == .scan) while (main.state == .refresh or main.state == .scan)