mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
src: update to standard library changes in Zig 0.12.0-dev.3385+3a836b480
* rearrangment of entries in `std.os` and `std.c`, `std.posix` finally extracted in https://github.com/ziglang/zig/pull/19354 . Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
This commit is contained in:
parent
8ce5bae872
commit
946d2a0316
3 changed files with 20 additions and 20 deletions
|
|
@ -365,7 +365,7 @@ fn spawnShell() void {
|
||||||
else
|
else
|
||||||
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.posix.getenvZ("NCDU_SHELL") orelse std.posix.getenvZ("SHELL") orelse "/bin/sh";
|
||||||
var child = std.process.Child.init(&.{shell}, allocator);
|
var child = std.process.Child.init(&.{shell}, allocator);
|
||||||
child.cwd = path.items;
|
child.cwd = path.items;
|
||||||
child.env_map = &env;
|
child.env_map = &env;
|
||||||
|
|
@ -433,7 +433,7 @@ pub fn main() void {
|
||||||
config.thousands_sep = span;
|
config.thousands_sep = span;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (std.os.getenvZ("NO_COLOR") == null) config.ui_color = .darkbg;
|
if (std.posix.getenvZ("NO_COLOR") == null) config.ui_color = .darkbg;
|
||||||
|
|
||||||
const loadConf = blk: {
|
const loadConf = blk: {
|
||||||
var args = std.process.ArgIteratorPosix.init();
|
var args = std.process.ArgIteratorPosix.init();
|
||||||
|
|
@ -446,11 +446,11 @@ pub fn main() void {
|
||||||
if (loadConf) {
|
if (loadConf) {
|
||||||
tryReadArgsFile("/etc/ncdu.conf");
|
tryReadArgsFile("/etc/ncdu.conf");
|
||||||
|
|
||||||
if (std.os.getenvZ("XDG_CONFIG_HOME")) |p| {
|
if (std.posix.getenvZ("XDG_CONFIG_HOME")) |p| {
|
||||||
const path = std.fs.path.joinZ(allocator, &.{p, "ncdu", "config"}) catch unreachable;
|
const path = std.fs.path.joinZ(allocator, &.{p, "ncdu", "config"}) catch unreachable;
|
||||||
defer allocator.free(path);
|
defer allocator.free(path);
|
||||||
tryReadArgsFile(path);
|
tryReadArgsFile(path);
|
||||||
} else if (std.os.getenvZ("HOME")) |p| {
|
} else if (std.posix.getenvZ("HOME")) |p| {
|
||||||
const path = std.fs.path.joinZ(allocator, &.{p, ".config", "ncdu", "config"}) catch unreachable;
|
const path = std.fs.path.joinZ(allocator, &.{p, ".config", "ncdu", "config"}) catch unreachable;
|
||||||
defer allocator.free(path);
|
defer allocator.free(path);
|
||||||
tryReadArgsFile(path);
|
tryReadArgsFile(path);
|
||||||
|
|
|
||||||
10
src/scan.zig
10
src/scan.zig
|
|
@ -32,17 +32,17 @@ const Stat = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read(parent: std.fs.Dir, name: [:0]const u8, follow: bool) !Stat {
|
fn read(parent: std.fs.Dir, name: [:0]const u8, follow: bool) !Stat {
|
||||||
const stat = try std.os.fstatatZ(parent.fd, name, if (follow) 0 else std.os.AT.SYMLINK_NOFOLLOW);
|
const stat = try std.posix.fstatatZ(parent.fd, name, if (follow) 0 else std.posix.AT.SYMLINK_NOFOLLOW);
|
||||||
return Stat{
|
return Stat{
|
||||||
.blocks = clamp(Stat, .blocks, stat.blocks),
|
.blocks = clamp(Stat, .blocks, stat.blocks),
|
||||||
.size = clamp(Stat, .size, stat.size),
|
.size = clamp(Stat, .size, stat.size),
|
||||||
.dev = truncate(Stat, .dev, stat.dev),
|
.dev = truncate(Stat, .dev, stat.dev),
|
||||||
.ino = truncate(Stat, .ino, stat.ino),
|
.ino = truncate(Stat, .ino, stat.ino),
|
||||||
.nlink = clamp(Stat, .nlink, stat.nlink),
|
.nlink = clamp(Stat, .nlink, stat.nlink),
|
||||||
.hlinkc = stat.nlink > 1 and !std.os.system.S.ISDIR(stat.mode),
|
.hlinkc = stat.nlink > 1 and !std.posix.S.ISDIR(stat.mode),
|
||||||
.dir = std.os.system.S.ISDIR(stat.mode),
|
.dir = std.posix.S.ISDIR(stat.mode),
|
||||||
.reg = std.os.system.S.ISREG(stat.mode),
|
.reg = std.posix.S.ISREG(stat.mode),
|
||||||
.symlink = std.os.system.S.ISLNK(stat.mode),
|
.symlink = std.posix.S.ISLNK(stat.mode),
|
||||||
.ext = .{
|
.ext = .{
|
||||||
.mtime = clamp(model.Ext, .mtime, stat.mtime().tv_sec),
|
.mtime = clamp(model.Ext, .mtime, stat.mtime().tv_sec),
|
||||||
.uid = truncate(model.Ext, .uid, stat.uid),
|
.uid = truncate(model.Ext, .uid, stat.uid),
|
||||||
|
|
|
||||||
22
src/ui.zig
22
src/ui.zig
|
|
@ -343,7 +343,7 @@ pub fn init() void {
|
||||||
clearScr();
|
clearScr();
|
||||||
if (main.config.nc_tty) {
|
if (main.config.nc_tty) {
|
||||||
const tty = c.fopen("/dev/tty", "r+");
|
const tty = c.fopen("/dev/tty", "r+");
|
||||||
if (tty == null) die("Error opening /dev/tty: {s}.\n", .{ c.strerror(@intFromEnum(std.c.getErrno(-1))) });
|
if (tty == null) die("Error opening /dev/tty: {s}.\n", .{ c.strerror(@intFromEnum(std.posix.errno(-1))) });
|
||||||
const term = c.newterm(null, tty, tty);
|
const term = c.newterm(null, tty, tty);
|
||||||
if (term == null) die("Error initializing ncurses.\n", .{});
|
if (term == null) die("Error initializing ncurses.\n", .{});
|
||||||
_ = c.set_term(term);
|
_ = c.set_term(term);
|
||||||
|
|
@ -473,14 +473,14 @@ pub fn addnum(bg: Bg, v: u64) void {
|
||||||
|
|
||||||
// Print a file mode, takes 10 columns
|
// Print a file mode, takes 10 columns
|
||||||
pub fn addmode(mode: u32) void {
|
pub fn addmode(mode: u32) void {
|
||||||
addch(switch (mode & std.os.S.IFMT) {
|
addch(switch (mode & std.posix.S.IFMT) {
|
||||||
std.os.S.IFDIR => 'd',
|
std.posix.S.IFDIR => 'd',
|
||||||
std.os.S.IFREG => '-',
|
std.posix.S.IFREG => '-',
|
||||||
std.os.S.IFLNK => 'l',
|
std.posix.S.IFLNK => 'l',
|
||||||
std.os.S.IFIFO => 'p',
|
std.posix.S.IFIFO => 'p',
|
||||||
std.os.S.IFSOCK => 's',
|
std.posix.S.IFSOCK => 's',
|
||||||
std.os.S.IFCHR => 'c',
|
std.posix.S.IFCHR => 'c',
|
||||||
std.os.S.IFBLK => 'b',
|
std.posix.S.IFBLK => 'b',
|
||||||
else => '?'
|
else => '?'
|
||||||
});
|
});
|
||||||
addch(if (mode & 0o400 > 0) 'r' else '-');
|
addch(if (mode & 0o400 > 0) 'r' else '-');
|
||||||
|
|
@ -491,7 +491,7 @@ pub fn addmode(mode: u32) void {
|
||||||
addch(if (mode & 0o2000 > 0) 's' else if (mode & 0o010 > 0) @as(u7, 'x') else '-');
|
addch(if (mode & 0o2000 > 0) 's' else if (mode & 0o010 > 0) @as(u7, 'x') else '-');
|
||||||
addch(if (mode & 0o004 > 0) 'r' else '-');
|
addch(if (mode & 0o004 > 0) 'r' else '-');
|
||||||
addch(if (mode & 0o002 > 0) 'w' else '-');
|
addch(if (mode & 0o002 > 0) 'w' else '-');
|
||||||
addch(if (mode & 0o1000 > 0) (if (std.os.S.ISDIR(mode)) @as(u7, 't') else 'T') else if (mode & 0o001 > 0) @as(u7, 'x') else '-');
|
addch(if (mode & 0o1000 > 0) (if (std.posix.S.ISDIR(mode)) @as(u7, 't') else 'T') else if (mode & 0o001 > 0) @as(u7, 'x') else '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a timestamp, takes 25 columns
|
// Print a timestamp, takes 25 columns
|
||||||
|
|
@ -592,5 +592,5 @@ pub fn getch(block: bool) i32 {
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
die("Error reading keyboard input, assuming TTY has been lost.\n(Potentially nonsensical error message: {s})\n",
|
die("Error reading keyboard input, assuming TTY has been lost.\n(Potentially nonsensical error message: {s})\n",
|
||||||
.{ c.strerror(@intFromEnum(std.c.getErrno(-1))) });
|
.{ c.strerror(@intFromEnum(std.posix.errno(-1))) });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue