summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/dump.zig b/src/dump.zig
index bb692481..93bf08cc 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -15,12 +15,7 @@ pub fn outPath(buf: *[1024:0]u8) ?[:0]const u8 {
if (std.c.getenv("PARDES_DUMP")) |p|
return std.fmt.bufPrintSentinel(buf, "{s}", .{std.mem.span(p)}, 0) catch null;
var dir_buf: [900]u8 = undefined;
- const dir = if (std.c.getenv("XDG_DATA_HOME")) |x|
- std.fmt.bufPrint(&dir_buf, "{s}/pardes", .{std.mem.span(x)}) catch return null
- else if (std.c.getenv("HOME")) |h|
- std.fmt.bufPrint(&dir_buf, "{s}/.local/share/pardes", .{std.mem.span(h)}) catch return null
- else
- return null;
+ const dir = defaultDirectory(&dir_buf) orelse return null;
var dz: [901:0]u8 = undefined;
@memcpy(dz[0..dir.len], dir);
dz[dir.len] = 0;
@@ -37,6 +32,15 @@ pub fn outPath(buf: *[1024:0]u8) ?[:0]const u8 {
ds.getSecondsIntoMinute(),
}, 0) catch null;
}
+/// The standard dump directory, without creating it or generating a filename.
+pub fn defaultDirectory(buf: []u8) ?[]const u8 {
+ if (std.c.getenv("XDG_DATA_HOME")) |x|
+ return std.fmt.bufPrint(buf, "{s}/pardes", .{std.mem.span(x)}) catch null;
+ if (std.c.getenv("HOME")) |h|
+ return std.fmt.bufPrint(buf, "{s}/.local/share/pardes", .{std.mem.span(h)}) catch null;
+ return null;
+}
+
pub const magic = "pardes-dump";
pub const version: u32 = 1;
pub const max_panes: usize = 16;