summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 14:53:46 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit12c257e624d3f1f80ca3df041b54026ff772d638 (patch)
tree6bba52da1148e167ed695e219bb3a9c742337d95 /src/dump.zig
parente56a8ba396566eaab818b6c742850b5842e880bb (diff)
downloadpardes-12c257e624d3f1f80ca3df041b54026ff772d638.tar.gz
pardes-12c257e624d3f1f80ca3df041b54026ff772d638.zip
A path typed with a leading ~ is the home directory, at every entry point that takes one, through one helper
Only DumpDir (dump.zig) and ShaderBuild expanded `~/`, each its own way. So a look at `~/notes.txt`, `name ~/x`, `Save ~/x`, ThemeFile, Restore and a quoted `pardes '~/x'` all took `~` as a directory of that name under the pane's. There is now one rule, filesystem.expandHome. A leading `~`, alone or before `/` or `:`, is $HOME, else the passwd entry's home; `~user` is that user's (getpwnam). As in a shell, it applies even beside a file named `~`, and `./~` names that file. Every entry point runs its typed path through it: - look, B3 and 9P, before any parsing, so `~/x:12`, `~/x:12:3` and `~/x:/re/` all work; - name, and a tag's rename; - Save <path>; - ThemeFile, DumpDir, Restore and ShaderBuild's shader files; - the forwarding launch. Recent rows are not shown with `~` and need nothing. How names are shown is unchanged. Tests: expandHome's cases, and HOME unset (passwd), with HOME passed in rather than set, since setenv moves the environ a spawned child reads. fs.py covers Save into missing directories under `~`, `name ~/x`, a look at `~/x:3`, and a forwarded `pardes '~/x'`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/dump.zig b/src/dump.zig
index 1cc115be..8e767240 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -100,13 +100,10 @@ fn hostEnv(name: [*:0]const u8) ?[*:0]u8 {
/// setting when set (a leading `~/` is the home directory), else the default.
pub fn directory(buf: []u8, dir_setting: []const u8) ?[]const u8 {
if (dir_setting.len == 0) return defaultDirectory(buf);
- var joined: [2048]u8 = undefined;
+ var joined: [4096]u8 = undefined;
// `~/x`, else a relative one from the directory pardes started in: the
// same place however it was written, and shown so.
- const raw = if (std.mem.startsWith(u8, dir_setting, "~/")) (if (hostEnv("HOME")) |h|
- std.fmt.bufPrint(&joined, "{s}/{s}", .{ std.mem.span(h), dir_setting[2..] }) catch return null
- else
- dir_setting) else dir_setting;
+ const raw = pardes.filesystem.expandHome(dir_setting, &joined);
var fba_buf: [4096]u8 = undefined;
var fba = std.heap.FixedBufferAllocator.init(&fba_buf);
var cwd_buf: [1024]u8 = undefined;