summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/9p_io.zig4
-rw-r--r--src/Db.zig18
-rw-r--r--src/Handover.zig2
-rw-r--r--src/Store.zig2
-rw-r--r--src/config.zig26
-rw-r--r--src/crash.zig6
-rw-r--r--src/dump.zig8
-rw-r--r--src/file_watch.zig6
-rw-r--r--src/fonts.zig4
-rw-r--r--src/fs.zig6
-rw-r--r--src/grammar_manifest.zig2
-rw-r--r--src/host_io.zig60
-rw-r--r--src/main.zig12
13 files changed, 78 insertions, 78 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 6e9148b8..70bd0bbf 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -1054,7 +1054,7 @@ test "the socket name is a third prefix in the shared directory" {
var buf: [sun_path_len]u8 = undefined;
const p = socketPath(&buf, "/run/user/1000", "t9srv").?;
try testing.expectEqualStrings("/run/user/1000/pardes-9p-t9srv.sock", p);
- try testing.expect(!std.mem.startsWith(u8, std.fs.path.basename(p), "pardes-detached-"));
+ try testing.expect(!std.mem.startsWith(u8, std.Io.Dir.path.basename(p), "pardes-detached-"));
}
test "a name that is not one path component is no address at all" {
@@ -1760,7 +1760,7 @@ pub fn exportEnv(serial: u32, adopts: bool) void {
fn exportMount(sock_path: []const u8) void {
const mntgen = if (libc.getenv("NINE_MNTGEN")) |v| std.mem.eql(u8, std.mem.span(v), "1") else false;
const root = if (libc.getenv("NINE_MOUNT")) |v| std.mem.span(v) else "";
- const base = std.fs.path.basename(sock_path);
+ const base = std.Io.Dir.path.basename(sock_path);
const sock_prefix = "pardes-9p-";
const suffix = ".sock";
if (mntgen and root.len > 0 and std.mem.startsWith(u8, base, sock_prefix) and std.mem.endsWith(u8, base, suffix) and base.len > sock_prefix.len + suffix.len) {
diff --git a/src/Db.zig b/src/Db.zig
index b79bf315..27557ac4 100644
--- a/src/Db.zig
+++ b/src/Db.zig
@@ -138,7 +138,7 @@ fn openDisk(gpa: std.mem.Allocator, path: []const u8) !*Open {
defer pardes.turn.back();
const io = ioOf();
const cwd = std.Io.Dir.cwd();
- if (std.fs.path.dirname(path)) |dir| try cwd.createDirPath(io, dir);
+ if (std.Io.Dir.path.dirname(path)) |dir| try cwd.createDirPath(io, dir);
const o = try gpa.create(Open);
errdefer gpa.destroy(o);
o.* = .{ .gpa = gpa, .buffer = .init(gpa), .where = undefined };
@@ -909,7 +909,7 @@ pub const Cache = struct {
std.fmt.bufPrint(&c.path_buf, "{s}/.cache/pardes/" ++ name, .{std.mem.span(home)})
else
return null) catch return null;
- std.Io.Dir.cwd().createDirPath(io, std.fs.path.dirname(where).?) catch return null;
+ std.Io.Dir.cwd().createDirPath(io, std.Io.Dir.path.dirname(where).?) catch return null;
c.path_len = where.len;
return c;
}
@@ -1142,7 +1142,7 @@ fn testWindow(dir: []const u8) !*Pardes {
return Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 48, .state = .disk, .startup_config = try std.fmt.bufPrint(&config, "DumpDir {s}\n", .{dir}) });
}
-fn testDir(tmp: *std.testing.TmpDir, buf: *[std.fs.max_path_bytes]u8) ![]const u8 {
+fn testDir(tmp: *std.testing.TmpDir, buf: *[std.Io.Dir.max_path_bytes]u8) ![]const u8 {
return buf[0..try tmp.dir.realPath(testing.io, buf)];
}
@@ -1156,7 +1156,7 @@ fn fileSize(dir: []const u8) u64 {
test "state file: two windows share Recent, each reading the other's commits on use; a busy lock delays, never loses" {
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = try testDir(&tmp, &dir_buf);
const a = try testWindow(dir);
defer a.deinit();
@@ -1202,7 +1202,7 @@ test "state file: two windows share Recent, each reading the other's commits on
test "state file: Recent holds the newest 200, the newest first, and a window started on it reads them so" {
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = try testDir(&tmp, &dir_buf);
const a = try testWindow(dir);
defer a.deinit();
@@ -1228,7 +1228,7 @@ test "state file: Recent holds the newest 200, the newest first, and a window st
test "state file: one that is no database of pardes's never stops pardes: it is kept aside, and a new one started" {
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = try testDir(&tmp, &dir_buf);
try tmp.dir.writeFile(testing.io, .{ .sub_path = file_name, .data = "\x00\xffnot a database at all\n7 3 0 0 /w/ok.zig\n" });
const a = try testWindow(dir);
@@ -1249,7 +1249,7 @@ test "state file: one a power loss tore is opened at its last whole commit, the
if (std.c.getenv("PARDES_DUMP") != null) return error.SkipZigTest;
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = try testDir(&tmp, &dir_buf);
var label_buf: [64]u8 = undefined;
var label: []const u8 = undefined;
@@ -1335,7 +1335,7 @@ test "state file: a Dump makes every directory missing on the way to its DumpDir
if (std.c.getenv("PARDES_DUMP") != null) return error.SkipZigTest;
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const base = try testDir(&tmp, &dir_buf);
var setting: [4200]u8 = undefined;
const dir = try std.fmt.bufPrint(&setting, "{s}/fresh/.local/share/pardes", .{base});
@@ -1352,7 +1352,7 @@ test "state file: a Dump makes every directory missing on the way to its DumpDir
test "state file: Recent is read once from the file it replaced, else from the store before that, both left where they are" {
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = try testDir(&tmp, &dir_buf);
try tmp.dir.createDirPath(testing.io, "old");
try tmp.dir.createDirPath(testing.io, "older");
diff --git a/src/Handover.zig b/src/Handover.zig
index fdd263e9..23baf4ad 100644
--- a/src/Handover.zig
+++ b/src/Handover.zig
@@ -394,7 +394,7 @@ fn carry(io: std.Io, job: *Job) void {
if (under) |dial| {
var line_buf: [600]u8 = undefined;
const line = std.fmt.bufPrint(&line_buf, "adopt {s}\n", .{job.path}) catch return job.post(job.post_ctx, job.seq, false, "its dump's name is too long");
- const name = std.fs.path.basename(dial);
+ const name = std.Io.Dir.path.basename(dial);
if (ninep_io.Client.write(job.gpa, dial, "ctl", line)) {
return job.post(job.post_ctx, job.seq, true, std.fmt.bufPrint(&words, "pardes/{s}", .{name}) catch "another window");
} else |err| return job.post(job.post_ctx, job.seq, false, std.fmt.bufPrint(&words, "pardes/{s} would not take it: {s}", .{
diff --git a/src/Store.zig b/src/Store.zig
index afe07742..1545e537 100644
--- a/src/Store.zig
+++ b/src/Store.zig
@@ -285,7 +285,7 @@ test "store: this session keeps its newest 64 closed panes" {
test "store: a closed pane comes back where it was, its rows from the pane that took them, nothing else moving; Panes lists it, marked" {
var tmp = testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
const p = try testWindow(dir);
defer p.deinit();
diff --git a/src/config.zig b/src/config.zig
index 2cecd2be..c89ab2e6 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -1318,14 +1318,14 @@ pub const User = struct {
// Relative XDG_CONFIG_HOME values are ignored.
pub fn path(gpa: std.mem.Allocator, env: *const std.process.Environ.Map) !?[]u8 {
- if (env.get("XDG_CONFIG_HOME")) |base| if (base.len != 0 and std.fs.path.isAbsolute(base))
- return try std.fs.path.join(gpa, &.{ base, "pardes" });
+ if (env.get("XDG_CONFIG_HOME")) |base| if (base.len != 0 and std.Io.Dir.path.isAbsolute(base))
+ return try std.Io.Dir.path.join(gpa, &.{ base, "pardes" });
const home = env.get("HOME") orelse return null;
if (home.len == 0) return null;
if (builtin.os.tag == .macos)
- return try std.fs.path.join(gpa, &.{ home, "Library", "Application Support", "pardes" });
- return try std.fs.path.join(gpa, &.{ home, ".config", "pardes" });
+ return try std.Io.Dir.path.join(gpa, &.{ home, "Library", "Application Support", "pardes" });
+ return try std.Io.Dir.path.join(gpa, &.{ home, ".config", "pardes" });
}
// The caller's allocator owns these slices, including paths when init is absent.
@@ -1341,7 +1341,7 @@ pub const User = struct {
env: *const std.process.Environ.Map,
) Found {
const config_dir = (path(gpa, env) catch return .{}) orelse return .{};
- const config_path = std.fs.path.join(gpa, &.{ config_dir, init_name }) catch return .{ .dir = config_dir };
+ const config_path = std.Io.Dir.path.join(gpa, &.{ config_dir, init_name }) catch return .{ .dir = config_dir };
return .{
.dir = config_dir,
.path = config_path,
@@ -1372,7 +1372,7 @@ pub const User = struct {
test "config loader reads init inside the config directory" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- var base_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const base_len = try tmp.dir.realPath(std.testing.io, &base_buf);
var env: std.process.Environ.Map = .init(std.testing.allocator);
@@ -1382,9 +1382,9 @@ pub const User = struct {
const missing = load(std.testing.io, std.testing.allocator, &env);
defer std.testing.allocator.free(missing.dir.?);
defer std.testing.allocator.free(missing.path.?);
- const expected_dir = try std.fs.path.join(std.testing.allocator, &.{ base_buf[0..base_len], "pardes" });
+ const expected_dir = try std.Io.Dir.path.join(std.testing.allocator, &.{ base_buf[0..base_len], "pardes" });
defer std.testing.allocator.free(expected_dir);
- const expected = try std.fs.path.join(std.testing.allocator, &.{ expected_dir, init_name });
+ const expected = try std.Io.Dir.path.join(std.testing.allocator, &.{ expected_dir, init_name });
defer std.testing.allocator.free(expected);
try std.testing.expectEqualStrings(expected_dir, missing.dir.?);
try std.testing.expectEqualStrings(expected, missing.path.?);
@@ -1407,7 +1407,7 @@ pub const User = struct {
config_dir: []const u8,
theme_values: anytype,
) ![]u8 {
- const out_dir = try std.fs.path.join(gpa, &.{ config_dir, builtin_themes_subdir });
+ const out_dir = try std.Io.Dir.path.join(gpa, &.{ config_dir, builtin_themes_subdir });
errdefer gpa.free(out_dir);
try std.Io.Dir.cwd().createDirPath(io, out_dir);
@@ -1418,7 +1418,7 @@ pub const User = struct {
const filename = try std.fmt.allocPrint(gpa, "{s}.zon", .{theme_value.name});
defer gpa.free(filename);
- const output_path = try std.fs.path.join(gpa, &.{ out_dir, filename });
+ const output_path = try std.Io.Dir.path.join(gpa, &.{ out_dir, filename });
defer gpa.free(output_path);
try std.Io.Dir.cwd().writeFile(io, .{
.sub_path = output_path,
@@ -1433,7 +1433,7 @@ pub const User = struct {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- var base_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const base_len = try tmp.dir.realPath(io, &base_buf);
const Sample = struct { name: []const u8, rgb: [3]u8 };
const samples = [_]Sample{
@@ -1442,11 +1442,11 @@ pub const User = struct {
};
const output = try dumpThemes(io, gpa, base_buf[0..base_len], &samples);
defer gpa.free(output);
- const expected = try std.fs.path.join(gpa, &.{ base_buf[0..base_len], builtin_themes_subdir });
+ const expected = try std.Io.Dir.path.join(gpa, &.{ base_buf[0..base_len], builtin_themes_subdir });
defer gpa.free(expected);
try std.testing.expectEqualStrings(expected, output);
- const one_path = try std.fs.path.join(gpa, &.{ output, "one.zon" });
+ const one_path = try std.Io.Dir.path.join(gpa, &.{ output, "one.zon" });
defer gpa.free(one_path);
const bytes = try std.Io.Dir.cwd().readFileAlloc(io, one_path, gpa, .limited(4096));
defer gpa.free(bytes);
diff --git a/src/crash.zig b/src/crash.zig
index 998cc982..26e810ac 100644
--- a/src/crash.zig
+++ b/src/crash.zig
@@ -201,12 +201,12 @@ test "a crash record names the build, appends, and carries the panic message" {
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- var base_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const base_len = try tmp.dir.realPath(io, &base_buf);
// A directory that does NOT exist yet, which is the case that matters: the
// user who has never written an init file is the likeliest reporter.
- const config_dir = try std.fs.path.join(gpa, &.{ base_buf[0..base_len], "pardes" });
+ const config_dir = try std.Io.Dir.path.join(gpa, &.{ base_buf[0..base_len], "pardes" });
defer gpa.free(config_dir);
const saved_len = dir_len;
defer dir_len = saved_len;
@@ -219,7 +219,7 @@ test "a crash record names the build, appends, and carries the panic message" {
recording.store(false, .seq_cst);
record("second boom");
- const path = try std.fs.path.join(gpa, &.{ config_dir, name });
+ const path = try std.Io.Dir.path.join(gpa, &.{ config_dir, name });
defer gpa.free(path);
const bytes = try std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(1 << 20));
defer gpa.free(bytes);
diff --git a/src/dump.zig b/src/dump.zig
index 0507fb4f..ba159325 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -52,8 +52,8 @@ pub fn directory(buf: []u8, dir_setting: []const u8) ?[]const u8 {
var fba_buf: [4096]u8 = undefined;
var fba = std.heap.FixedBufferAllocator.init(&fba_buf);
var cwd_buf: [1024]u8 = undefined;
- const cwd: []const u8 = if (std.fs.path.isAbsolute(raw)) "/" else if (std.c.getcwd(&cwd_buf, cwd_buf.len)) |c| std.mem.span(@as([*:0]const u8, @ptrCast(c))) else "/";
- const resolved = std.fs.path.resolvePosix(fba.allocator(), &.{ cwd, raw }) catch return null;
+ const cwd: []const u8 = if (std.Io.Dir.path.isAbsolute(raw)) "/" else if (std.c.getcwd(&cwd_buf, cwd_buf.len)) |c| std.mem.span(@as([*:0]const u8, @ptrCast(c))) else "/";
+ const resolved = std.Io.Dir.path.resolvePosix(fba.allocator(), &.{ cwd, raw }) catch return null;
return std.fmt.bufPrint(buf, "{s}", .{resolved}) catch null;
}
@@ -62,7 +62,7 @@ test "a DumpDir reads back absolute, however it was written" {
try std.testing.expectEqualStrings("/tmp/dumps", directory(&buf, "/tmp/dumps/").?);
try std.testing.expectEqualStrings("/tmp/dumps", directory(&buf, "/tmp//x/../dumps").?);
const rel = directory(&buf, "rel/");
- try std.testing.expect(std.fs.path.isAbsolute(rel.?) and std.mem.endsWith(u8, rel.?, "/rel"));
+ try std.testing.expect(std.Io.Dir.path.isAbsolute(rel.?) and std.mem.endsWith(u8, rel.?, "/rel"));
}
/// The standard dump directory, without creating it or generating a filename.
@@ -139,7 +139,7 @@ pub fn dumpTo(p: *Pardes, to: ?[]const u8) !void {
pub fn restoreFile(name: []const u8, dir_setting: []const u8, out: *[4096]u8) ?[]const u8 {
const path = filesystem.restorePath(name, dir_setting, out);
if (std.mem.indexOfScalar(u8, name, '/') != null or std.mem.startsWith(u8, name, "~")) return path;
- return if (std.fs.path.isAbsolute(path)) path else null;
+ return if (std.Io.Dir.path.isAbsolute(path)) path else null;
}
/// What a Restore of `name` reads, `gpa`'s: the file it names (an image,
diff --git a/src/file_watch.zig b/src/file_watch.zig
index 812c1791..1e8c450a 100644
--- a/src/file_watch.zig
+++ b/src/file_watch.zig
@@ -414,7 +414,7 @@ pub fn watchPane(
pardes.turn.yield();
defer pardes.turn.back();
const stat = @import("fs.zig").statPath(std.Io.Threaded.global_single_threaded.io(), watched_path, .{}) catch null;
- const dir = if (stat != null and stat.?.kind == .directory) watched_path else std.fs.path.dirname(watched_path) orelse ".";
+ const dir = if (stat != null and stat.?.kind == .directory) watched_path else std.Io.Dir.path.dirname(watched_path) orelse ".";
var dir_buf: [4096:0]u8 = undefined;
if (dir.len >= dir_buf.len) return;
@memcpy(dir_buf[0..dir.len], dir);
@@ -864,9 +864,9 @@ test "theme watch reloads valid ZON and keeps the last theme across a bad save"
const gpa = std.testing.allocator;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- var base_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const base_len = try tmp.dir.realPath(io, &base_buf);
- const path = try std.fs.path.join(gpa, &.{ base_buf[0..base_len], "mine.zon" });
+ const path = try std.Io.Dir.path.join(gpa, &.{ base_buf[0..base_len], "mine.zon" });
defer gpa.free(path);
var first = pardes.themes[0];
diff --git a/src/fonts.zig b/src/fonts.zig
index a49ef9e4..505190bd 100644
--- a/src/fonts.zig
+++ b/src/fonts.zig
@@ -123,7 +123,7 @@ fn scan(
if (e.depth() < max_depth) w.enter(io, e) catch {};
continue;
}
- const ext = std.fs.path.extension(e.basename);
+ const ext = std.Io.Dir.path.extension(e.basename);
// .ttc is a collection: several cuts of one family in a single
// file, which is how macOS ships Menlo, Courier and a third of
// everything else. The probe below reads face 0 out of one, and
@@ -392,7 +392,7 @@ test "the walk finds this machine's monospace faces" {
try std.testing.expect(font.name.len > 0);
try std.testing.expect(font.path[0] == '/');
// The name is the stem, so the file it came from is always longer.
- try std.testing.expect(std.fs.path.basename(font.path).len > font.name.len);
+ try std.testing.expect(std.Io.Dir.path.basename(font.path).len > font.name.len);
}
// macOS ships Menlo, and ships it inside a .ttc. It is the one face this
diff --git a/src/fs.zig b/src/fs.zig
index b5ee2d9e..e3976884 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -167,7 +167,7 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply {
if (req.op == .release) return .{ .tag = req.tag };
const io = std.Io.Threaded.global_single_threaded.io();
const stat = pardes.tape.site(.os_stat, null, osStat, .{ io, path }) catch return Reply.fail(req.tag, E.NOENT);
- const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = stat.mtime };
+ const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.Io.Dir.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = stat.mtime };
switch (req.op) {
.getattr => return .{ .tag = req.tag, .attr = attr },
.open => {
@@ -710,7 +710,7 @@ fn makeDirsHost(dir: []const u8) void {
pub fn deniedAbove(dir: []const u8) bool {
if (comptime !platform_has_fs) return false;
var at: ?[]const u8 = dir;
- while (at) |d| : (at = std.fs.path.dirname(d)) {
+ while (at) |d| : (at = std.Io.Dir.path.dirname(d)) {
var z: [4096]u8 = undefined;
const dz = std.fmt.bufPrintSentinel(&z, "{s}", .{d}, 0) catch return false;
if (libc.access(dz.ptr, 0) != 0) continue; // F_OK
@@ -1120,7 +1120,7 @@ pub fn readRestore(gpa: std.mem.Allocator, typed: []const u8, dir_setting: []con
pub fn restorePath(typed: []const u8, dir_setting: []const u8, out: *[4096]u8) []const u8 {
var home_buf: [4096]u8 = undefined;
const path = expandHome(typed, &home_buf);
- if (!std.fs.path.isAbsolute(path)) {
+ if (!std.Io.Dir.path.isAbsolute(path)) {
var dir_buf: [4096]u8 = undefined;
if (@import("dump.zig").directory(&dir_buf, dir_setting)) |base| {
var buf: [4096]u8 = undefined;
diff --git a/src/grammar_manifest.zig b/src/grammar_manifest.zig
index d6666729..38c54916 100644
--- a/src/grammar_manifest.zig
+++ b/src/grammar_manifest.zig
@@ -87,7 +87,7 @@ pub fn byName(name: []const u8) ?usize {
/// The grammar a path's extension selects, in any case.
pub fn byPath(path: []const u8) ?usize {
- const ext = std.fs.path.extension(path);
+ const ext = std.Io.Dir.path.extension(path);
if (ext.len == 0) return null;
for (all, 0..) |g, i| for (g.exts) |e| if (std.ascii.eqlIgnoreCase(ext, e)) return i;
return null;
diff --git a/src/host_io.zig b/src/host_io.zig
index 44061c4d..a363a578 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -919,7 +919,7 @@ pub const Lsp = struct {
const job = try snapshot(gpa, core, .{ .id = 1, .kind = .hover, .pane = @intCast(core.view().active), .offset = 0, .arg = "" });
defer job.free(gpa);
try std.testing.expectEqualStrings(case.native, job.path);
- try std.testing.expectEqualStrings(std.fs.path.dirname(case.native).?, job.root);
+ try std.testing.expectEqualStrings(std.Io.Dir.path.dirname(case.native).?, job.root);
try std.testing.expectEqualStrings(case.path, pane.file.?.path);
}
}
@@ -1312,11 +1312,11 @@ pub const Shell = struct {
try tmp.dir.createDirPath(std.testing.io, "paths.d");
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "paths.d/20-last", .data = "/opt/local/bin\n/usr/bin\n" });
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "paths.d/10-first", .data = "/opt/homebrew/bin\n/bin\n" });
- var root_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var root_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const root = root_buf[0..try tmp.dir.realPath(std.testing.io, &root_buf)];
- var file_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var file_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const paths_file = try std.fmt.bufPrintSentinel(&file_buf, "{s}/paths", .{root}, 0);
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const paths_dir = try std.fmt.bufPrint(&dir_buf, "{s}/paths.d", .{root});
var buf: [path_capacity]u8 = undefined;
var len: usize = 0;
@@ -1348,7 +1348,7 @@ pub const Shell = struct {
const base = if (std.mem.lastIndexOfScalar(u8, bin, '/')) |s| bin[s + 1 ..] else bin;
for ([_][]const u8{ "sh", "dash", "zsh", "ksh", "mksh", "yash", "nu", "elvish", "xonsh", "tcsh", "csh" }) |known|
if (std.mem.eql(u8, base, known)) return .none;
- var real: [std.fs.max_path_bytes]u8 = undefined;
+ var real: [std.Io.Dir.max_path_bytes]u8 = undefined;
if (libc.realpath(path, &real)) |r| {
const by_link = family(std.mem.span(@as([*:0]const u8, @ptrCast(r))));
if (by_link != .none) return by_link;
@@ -1577,7 +1577,7 @@ pub const Shell = struct {
};
// Resolve in the parent. The path buffer and prompt files must survive through exec.
- pub fn resolve(bin: []const u8, buf: *[std.fs.max_path_bytes]u8, prompt_rcs: *const PromptFiles) Spawn {
+ pub fn resolve(bin: []const u8, buf: *[std.Io.Dir.max_path_bytes]u8, prompt_rcs: *const PromptFiles) Spawn {
const path = find(bin, buf) orelse fallback(buf);
const marks: [2]?[*:0]const u8 = switch (familyOf(path)) {
.bash => if (prompt_rcs.bashPath()) |rc| .{ "--rcfile", rc.ptr } else .{ null, null },
@@ -1607,7 +1607,7 @@ pub const Shell = struct {
/// A shell by its path or its name in the usual directories, or null.
/// A path may be under a mount this editor serves: the turn goes out
/// with the lookups (pardes.Turn.yield).
- pub fn find(bin: []const u8, buf: *[std.fs.max_path_bytes]u8) ?[*:0]const u8 {
+ pub fn find(bin: []const u8, buf: *[std.Io.Dir.max_path_bytes]u8) ?[*:0]const u8 {
if (bin.len == 0 or bin.len + 1 > buf.len) return null;
pardes.turn.yield();
defer pardes.turn.back();
@@ -1638,7 +1638,7 @@ pub const Shell = struct {
/// Why `bin` is no shell, for the words that name one (Term, Shell);
/// null when it is one.
pub fn refusal(bin: []const u8, said: []u8) ?[]const u8 {
- var buf: [std.fs.max_path_bytes]u8 = undefined;
+ var buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
if (find(bin, &buf)) |found| {
// A script whose `#!` names a program that is not there: its
// exec fails ENOENT as a missing shell's does, so told apart.
@@ -1697,7 +1697,7 @@ pub const Shell = struct {
try std.testing.expect(std.mem.endsWith(u8, refusal(plain, &said).?, "plain is not executable"));
}
- fn fallback(buf: *[std.fs.max_path_bytes]u8) [*:0]const u8 {
+ fn fallback(buf: *[std.Io.Dir.max_path_bytes]u8) [*:0]const u8 {
for (fallbacks) |f| {
@memcpy(buf[0..f.len], f);
buf[f.len] = 0;
@@ -1723,7 +1723,7 @@ pub const Shell = struct {
test "a path is taken at its word, a name is looked up, and both pick their own marks" {
if (builtin.os.tag == .windows) return;
- var buf: [std.fs.max_path_bytes]u8 = undefined;
+ var buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
var prompt_rcs = PromptFiles.init();
defer prompt_rcs.deinit();
@@ -1767,13 +1767,13 @@ pub const Shell = struct {
test "prompt files are one per content under the runtime dir, or private and cleaned up without it" {
if (builtin.os.tag == .windows) return;
- var saved_buf: [std.fs.max_path_bytes:0]u8 = @splat(0);
+ var saved_buf: [std.Io.Dir.max_path_bytes:0]u8 = @splat(0);
const saved: ?[:0]const u8 = if (std.c.getenv("XDG_RUNTIME_DIR")) |v| std.fmt.bufPrintSentinel(&saved_buf, "{s}", .{std.mem.span(v)}, 0) catch null else null;
defer _ = if (saved) |v| setenv("XDG_RUNTIME_DIR", v.ptr, 1) else testUnsetenv("XDG_RUNTIME_DIR");
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
- var dir_buf: [std.fs.max_path_bytes:0]u8 = @splat(0);
+ var dir_buf: [std.Io.Dir.max_path_bytes:0]u8 = @splat(0);
const dir_len = try tmp.dir.realPath(std.testing.io, &dir_buf);
_ = setenv("XDG_RUNTIME_DIR", dir_buf[0..dir_len :0].ptr, 1);
@@ -1797,7 +1797,7 @@ pub const Shell = struct {
a.deinit();
b.deinit();
try std.testing.expect(libc.access(&kept, 0) == 0);
- try tmp.dir.writeFile(std.testing.io, .{ .sub_path = std.fs.path.basename(kept[0..a_bash.len]), .data = "half" });
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = std.Io.Dir.path.basename(kept[0..a_bash.len]), .data = "half" });
var c = PromptFiles.init();
defer c.deinit();
try std.testing.expectEqualStrings(bash_rc, readSmall(c.bashPath().?, &buf) orelse return error.ReadFailed);
@@ -1810,7 +1810,7 @@ pub const Shell = struct {
const d_bash = d.bashPath() orelse return error.TempCreateFailed;
try std.testing.expect(!std.mem.eql(u8, d_bash, e.bashPath().?));
try std.testing.expect(std.mem.startsWith(u8, d_bash, "/tmp/pardes-osc133-bash-"));
- try std.testing.expectEqual(@as(?std.c.pid_t, std.c.getpid()), rcPid(std.fs.path.basename(d_bash)));
+ try std.testing.expectEqual(@as(?std.c.pid_t, std.c.getpid()), rcPid(std.Io.Dir.path.basename(d_bash)));
@memcpy(kept[0..d_bash.len], d_bash);
kept[d_bash.len] = 0;
d.deinit();
@@ -1985,15 +1985,15 @@ pub const ChildEnv = struct {
/// another; plain `pardes -` where the path cannot be read or quoted.
fn pardesPagers() []const [*:0]const u8 {
const S = struct {
- var pager: [std.fs.max_path_bytes + 32:0]u8 = undefined;
- var git_pager: [std.fs.max_path_bytes + 32:0]u8 = undefined;
- var systemd_pager: [std.fs.max_path_bytes + 32:0]u8 = undefined;
+ var pager: [std.Io.Dir.max_path_bytes + 32:0]u8 = undefined;
+ var git_pager: [std.Io.Dir.max_path_bytes + 32:0]u8 = undefined;
+ var systemd_pager: [std.Io.Dir.max_path_bytes + 32:0]u8 = undefined;
var entries: [4][*:0]const u8 = undefined;
var ready = false;
};
if (!S.ready) {
- var exe_buf: [std.fs.max_path_bytes]u8 = undefined;
- var quoted_buf: [std.fs.max_path_bytes + 2]u8 = undefined;
+ var exe_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ var quoted_buf: [std.Io.Dir.max_path_bytes + 2]u8 = undefined;
const n = if (comptime builtin.os.tag == .linux) libc.readlink("/proc/self/exe", &exe_buf, exe_buf.len) else -1;
const exe: []const u8 = if (n > 0 and @as(usize, @intCast(n)) < exe_buf.len) exe_buf[0..@intCast(n)] else "pardes";
const command = pagerCommand(exe, &quoted_buf);
@@ -2176,7 +2176,7 @@ pub fn forkShell(
break :dir path;
};
var master: c_int = -1;
- var path_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var path_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
// A terminal opened on a shell of its own (`Term fish`) runs that one,
// copied: looking it up gives the turn up, and the pane may go.
var own_buf: [256]u8 = undefined;
@@ -2390,7 +2390,7 @@ extern "c" fn proc_pidinfo(pid: c_int, flavor: c_int, arg: u64, buffer: *anyopaq
/// prompt files (bash, zsh, fish), which a pane's runs wait on.
pub fn marksPrompts(pid: libc.pid_t) bool {
var buf: [pardes.memory.limits.host_path_cap + 1]u8 = undefined;
- const exe = std.fs.path.basename(processExe(pid, &buf) orelse return false);
+ const exe = std.Io.Dir.path.basename(processExe(pid, &buf) orelse return false);
for ([_][]const u8{ "bash", "zsh", "fish" }) |shell| if (std.mem.eql(u8, exe, shell)) return true;
return false;
}
@@ -2465,8 +2465,8 @@ fn kernProc(pid: libc.pid_t, what: c_int, buf: []u8) ?usize {
/// foreground group when that is the same shell, and while a job holds the
/// foreground there is no answer, the last one standing.
pub fn ttyCwd(shell_pid: libc.pid_t, master_fd: c_int, shell_exe: []const u8, buf: []u8) ?[]const u8 {
- var exe_buf: [std.fs.max_path_bytes]u8 = undefined;
- var shell_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var exe_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ var shell_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const shell = realShell(shell_exe, &shell_buf) orelse return shellCwd(shell_pid, buf);
const exe = processExe(shell_pid, &exe_buf) orelse return shellCwd(shell_pid, buf);
if (std.mem.eql(u8, exe, shell)) return shellCwd(shell_pid, buf);
@@ -2477,8 +2477,8 @@ pub fn ttyCwd(shell_pid: libc.pid_t, master_fd: c_int, shell_exe: []const u8, bu
}
/// `shell_exe` as /proc/<pid>/exe would read it: its links followed.
-fn realShell(shell_exe: []const u8, buf: *[std.fs.max_path_bytes]u8) ?[]const u8 {
- var z: [std.fs.max_path_bytes:0]u8 = undefined;
+fn realShell(shell_exe: []const u8, buf: *[std.Io.Dir.max_path_bytes]u8) ?[]const u8 {
+ var z: [std.Io.Dir.max_path_bytes:0]u8 = undefined;
const path = std.fmt.bufPrintSentinel(&z, "{s}", .{shell_exe}, 0) catch return null;
const r = libc.realpath(path, buf) orelse return null;
return std.mem.span(@as([*:0]const u8, @ptrCast(r)));
@@ -2600,8 +2600,8 @@ const tty_probe_platform = switch (builtin.os.tag) {
};
const TtyProbe = struct {
- self_exe: [std.fs.max_path_bytes]u8 = undefined,
- exe: [std.fs.max_path_bytes]u8 = undefined,
+ self_exe: [std.Io.Dir.max_path_bytes]u8 = undefined,
+ exe: [std.Io.Dir.max_path_bytes]u8 = undefined,
blob: [4096]u8 = undefined,
pending: [occ_max_visited]Node = undefined,
@@ -3060,7 +3060,7 @@ pub fn foregroundName(shell_pid: libc.pid_t, master_fd: c_int, buf: []u8) ?[]con
if (comptime builtin.os.tag != .linux and builtin.os.tag != .freebsd) return null;
const fg = tcgetpgrp(master_fd);
if (fg <= 0 or fg == shell_pid) return null;
- if (comptime builtin.os.tag == .freebsd) return std.fs.path.basename(processExe(fg, buf) orelse return null);
+ if (comptime builtin.os.tag == .freebsd) return std.Io.Dir.path.basename(processExe(fg, buf) orelse return null);
var name: [64:0]u8 = undefined;
const path = std.fmt.bufPrintSentinel(&name, "/proc/{d}/comm", .{@as(u32, @intCast(fg))}, 0) catch return null;
const comm = std.mem.trimEnd(u8, readProc(path, buf) orelse return null, "\n");
@@ -3534,8 +3534,8 @@ test "the walk reaches the leaf: bash -c 'sleep 30' takes the tty" {
var pending: usize = 0;
try std.testing.expectEqual(Pushed.pushed, pushChildren(&probe, &pending, sh.pid, 1));
try std.testing.expectEqual(@as(usize, 1), pending);
- var wrapper_buf: [std.fs.max_path_bytes]u8 = undefined;
- var shell_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var wrapper_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ var shell_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
try std.testing.expectEqualStrings(
processExe(sh.pid, &shell_buf).?,
processExe(probe.pending[0].pid, &wrapper_buf).?,
diff --git a/src/main.zig b/src/main.zig
index 623b6033..68542b3e 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -639,9 +639,9 @@ fn nativeMain(std_init: std.process.Init) !void {
// A name not there yet, as acme's B takes one: its directory
// resolved and the name kept, a pane made for it that Save
// creates the file from.
- const base = std.fs.path.basename(target.path);
+ const base = std.Io.Dir.path.basename(target.path);
if (base.len == 0 or std.mem.eql(u8, base, ".") or std.mem.eql(u8, base, "..")) Refuse.with(init.io, word, error.NotAFileName);
- const dir = pardes.filesystem.resolveOs(std.fs.path.dirname(target.path) orelse ".", &realbuf) orelse {
+ const dir = pardes.filesystem.resolveOs(std.Io.Dir.path.dirname(target.path) orelse ".", &realbuf) orelse {
// Its directory not there either: the name made absolute as
// written, and the pane's Save makes the directories.
var cwd_buf: [4096]u8 = undefined;
@@ -650,7 +650,7 @@ fn nativeMain(std_init: std.process.Init) !void {
const absolute = std.fs.path.resolvePosix(arena, &.{ cwd, target.path }) catch |err| Refuse.with(init.io, word, err);
// Missing because one above may not be searched or written:
// its Save could never make it, so refused now.
- if (pardes.filesystem.deniedAbove(std.fs.path.dirname(absolute) orelse "/")) Refuse.with(init.io, word, error.DirectoryNotWritable);
+ if (pardes.filesystem.deniedAbove(std.Io.Dir.path.dirname(absolute) orelse "/")) Refuse.with(init.io, word, error.DirectoryNotWritable);
break :named absolute;
};
// A directory that is there but may not be read or written: a
@@ -1111,9 +1111,9 @@ test {
/// $XDG_STATE_HOME/pardes, else ~/.local/state/pardes. A state file that
/// holds no Recent yet reads them once (Db.zig).
fn oldRecentDir(arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 {
- if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.fs.path.isAbsolute(base))
- return std.fs.path.join(arena, &.{ base, "pardes" }) catch null;
+ if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.Io.Dir.path.isAbsolute(base))
+ return std.Io.Dir.path.join(arena, &.{ base, "pardes" }) catch null;
const home = env.get("HOME") orelse return null;
if (home.len == 0) return null;
- return std.fs.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch null;
+ return std.Io.Dir.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch null;
}