summaryrefslogtreecommitdiff
path: root/libs/xdg
diff options
context:
space:
mode:
Diffstat (limited to 'libs/xdg')
m---------libs/xdg0
-rw-r--r--libs/xdg/xdg.zig36
2 files changed, 0 insertions, 36 deletions
diff --git a/libs/xdg b/libs/xdg
new file mode 160000
Subproject 0d9f7828de76bbae685be30b8f75a5aefad408f
diff --git a/libs/xdg/xdg.zig b/libs/xdg/xdg.zig
deleted file mode 100644
index 8466066..0000000
--- a/libs/xdg/xdg.zig
+++ /dev/null
@@ -1,36 +0,0 @@
1const std = @import("std");
2
3const Allocator = std.mem.Allocator;
4const Dir = std.fs.Dir;
5
6pub fn getDataHome(allocator: Allocator, app_name: []const u8) ![]u8 {
7 if (std.os.getenv("XDG_DATA_HOME")) |data_home| {
8 return std.fs.path.join(allocator, &.{ data_home, app_name });
9 }
10
11 if (std.os.getenv("HOME")) |home| {
12 return std.fs.path.join(allocator, &.{ home, ".local", "share", app_name });
13 }
14
15 return error.HomeNotFound;
16}
17
18pub fn getBinHome(allocator: Allocator) ![]u8 {
19 if (std.os.getenv("HOME")) |home| {
20 return std.fs.path.join(allocator, &.{ home, ".local", "bin" });
21 }
22
23 return error.HomeNotFound;
24}
25
26pub fn openDataHome(allocator: Allocator, app_name: []const u8) !Dir {
27 var data_home = try getDataHome(allocator, app_name);
28 defer allocator.free(data_home);
29 return try std.fs.cwd().makeOpenPath(data_home, .{});
30}
31
32pub fn openBinHome(allocator: Allocator) !Dir {
33 var bin_home = try getBinHome(allocator);
34 defer allocator.free(bin_home);
35 return try std.fs.cwd().makeOpenPath(bin_home, .{});
36}