mirror of
https://github.com/ziglang/zig.git
synced 2025-02-03 12:58:04 +00:00
std/fs: Support XDG_DATA_HOME
This is generally used for user-specific data on linux, with the default being ~/.local/share
This commit is contained in:
parent
1f10cf4edf
commit
da8d4d9225
@ -45,6 +45,10 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi
|
||||
return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname });
|
||||
},
|
||||
.linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => {
|
||||
if (os.getenv("XDG_DATA_HOME")) |xdg| {
|
||||
return fs.path.join(allocator, &[_][]const u8{ xdg, appname });
|
||||
}
|
||||
|
||||
const home_dir = os.getenv("HOME") orelse {
|
||||
// TODO look in /etc/passwd
|
||||
return error.AppDataDirUnavailable;
|
||||
|
Loading…
Reference in New Issue
Block a user