mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
update to Zig std library 0.10.0
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
parent
d523a77fdc
commit
3b4b88ab2a
3 changed files with 11 additions and 12 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, .{ .access_sub_paths = true, .iterate = false })
|
||||
var fd = dir.openDirZ(path, .{ .access_sub_paths = true }, false)
|
||||
catch |e| return err(e);
|
||||
var it = &d.sub;
|
||||
parent = d;
|
||||
|
|
|
|||
|
|
@ -343,8 +343,7 @@ fn spawnShell() void {
|
|||
env.put("NCDU_LEVEL", "1") catch unreachable;
|
||||
|
||||
const shell = std.os.getenvZ("NCDU_SHELL") orelse std.os.getenvZ("SHELL") orelse "/bin/sh";
|
||||
var child = std.ChildProcess.init(&.{shell}, allocator) catch unreachable;
|
||||
defer child.deinit();
|
||||
var child = std.ChildProcess.init(&.{shell}, allocator);
|
||||
child.cwd = path.items;
|
||||
child.env_map = &env;
|
||||
|
||||
|
|
|
|||
18
src/scan.zig
18
src/scan.zig
|
|
@ -450,10 +450,10 @@ 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.Dir, dir_dev: u64) void {
|
||||
var it = main.allocator.create(std.fs.Dir.Iterator) catch unreachable;
|
||||
fn scanDir(ctx: *Context, pat: *const exclude.Patterns, iterable_dir: std.fs.IterableDir, dir_dev: u64) void {
|
||||
var it = main.allocator.create(std.fs.IterableDir.Iterator) catch unreachable;
|
||||
defer main.allocator.destroy(it);
|
||||
it.* = dir.iterate();
|
||||
it.* = iterable_dir.iterate();
|
||||
while(true) {
|
||||
const entry = it.next() catch {
|
||||
ctx.setDirlistError();
|
||||
|
|
@ -471,7 +471,7 @@ fn scanDir(ctx: *Context, pat: *const exclude.Patterns, dir: std.fs.Dir, dir_dev
|
|||
continue;
|
||||
}
|
||||
|
||||
ctx.stat = Stat.read(dir, ctx.name, false) catch {
|
||||
ctx.stat = Stat.read(iterable_dir.dir, ctx.name, false) catch {
|
||||
ctx.addSpecial(.err);
|
||||
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 (Stat.read(dir, ctx.name, true)) |nstat| {
|
||||
if (Stat.read(iterable_dir.dir, ctx.name, true)) |nstat| {
|
||||
if (!nstat.dir) {
|
||||
ctx.stat = nstat;
|
||||
// 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 =
|
||||
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);
|
||||
continue;
|
||||
} else null;
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
||||
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";
|
||||
var buf: [sig.len]u8 = undefined;
|
||||
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())
|
||||
pub fn scan() void {
|
||||
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.fatal_error = e;
|
||||
while (main.state == .refresh or main.state == .scan)
|
||||
|
|
|
|||
Loading…
Reference in a new issue