mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-12 17:08:39 -09:00
Fixes for stdlib changes
This commit is contained in:
parent
f37362af36
commit
f7e774ee6e
4 changed files with 16 additions and 15 deletions
|
|
@ -45,8 +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, .{.no_follow = true}, false) catch |e| return err(e);
|
||||||
catch |e| return err(e);
|
|
||||||
var it = &d.sub;
|
var it = &d.sub;
|
||||||
parent = d;
|
parent = d;
|
||||||
defer parent = parent.parent.?;
|
defer parent = parent.parent.?;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
21
src/scan.zig
21
src/scan.zig
|
|
@ -450,8 +450,8 @@ 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, 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.* = dir.iterate();
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
@ -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(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(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,21 @@ 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) null
|
||||||
|
else if (dir.dir.openDirZ(ctx.name, .{ .no_follow = true }, true)) |d| std.fs.IterableDir{.dir = d}
|
||||||
|
else |_| {
|
||||||
ctx.addSpecial(.err);
|
ctx.addSpecial(.err);
|
||||||
continue;
|
continue;
|
||||||
} 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,13 +558,14 @@ 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().openDirZ(active_context.pathZ(), .{}, 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)
|
||||||
main.handleEvent(true, true);
|
main.handleEvent(true, true);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
var dir = std.fs.IterableDir{.dir = dir_};
|
||||||
defer dir.close();
|
defer dir.close();
|
||||||
var pat = exclude.getPatterns(active_context.pathZ());
|
var pat = exclude.getPatterns(active_context.pathZ());
|
||||||
defer pat.deinit();
|
defer pat.deinit();
|
||||||
|
|
|
||||||
|
|
@ -286,8 +286,8 @@ const styles = [_]StyleDef{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Style = lbl: {
|
pub const Style = lbl: {
|
||||||
var fields: [styles.len]std.builtin.TypeInfo.EnumField = undefined;
|
var fields: [styles.len]std.builtin.Type.EnumField = undefined;
|
||||||
var decls = [_]std.builtin.TypeInfo.Declaration{};
|
var decls = [_]std.builtin.Type.Declaration{};
|
||||||
inline for (styles) |s, i| {
|
inline for (styles) |s, i| {
|
||||||
fields[i] = .{
|
fields[i] = .{
|
||||||
.name = s.name,
|
.name = s.name,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue