Commit 0a70455095
Changed files (3)
lib
std
debug
lib/std/debug/Dwarf.zig
@@ -2275,9 +2275,11 @@ pub const ElfModule = struct {
break :dir std.fs.openDirAbsolute(path, .{}) catch break :blk;
}
if (std.posix.getenv("XDG_CACHE_HOME")) |cache_path| {
- const path = std.fs.path.join(gpa, &[_][]const u8{ cache_path, "debuginfod_client" }) catch break :blk;
- defer gpa.free(path);
- break :dir std.fs.openDirAbsolute(path, .{}) catch break :blk;
+ if (cache_path.len > 0) {
+ const path = std.fs.path.join(gpa, &[_][]const u8{ cache_path, "debuginfod_client" }) catch break :blk;
+ defer gpa.free(path);
+ break :dir std.fs.openDirAbsolute(path, .{}) catch break :blk;
+ }
}
if (std.posix.getenv("HOME")) |home_path| {
const path = std.fs.path.join(gpa, &[_][]const u8{ home_path, ".cache", "debuginfod_client" }) catch break :blk;
lib/std/fs/get_app_data_dir.zig
@@ -32,7 +32,9 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi
},
.linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => {
if (posix.getenv("XDG_DATA_HOME")) |xdg| {
- return fs.path.join(allocator, &[_][]const u8{ xdg, appname });
+ if (xdg.len > 0) {
+ return fs.path.join(allocator, &[_][]const u8{ xdg, appname });
+ }
}
const home_dir = posix.getenv("HOME") orelse {
src/introspect.zig
@@ -90,8 +90,11 @@ pub fn resolveGlobalCacheDir(allocator: mem.Allocator) ![]u8 {
if (builtin.os.tag != .windows) {
if (std.zig.EnvVar.XDG_CACHE_HOME.getPosix()) |cache_root| {
- return fs.path.join(allocator, &[_][]const u8{ cache_root, appname });
- } else if (std.zig.EnvVar.HOME.getPosix()) |home| {
+ if (cache_root.len > 0) {
+ return fs.path.join(allocator, &[_][]const u8{ cache_root, appname });
+ }
+ }
+ if (std.zig.EnvVar.HOME.getPosix()) |home| {
return fs.path.join(allocator, &[_][]const u8{ home, ".cache", appname });
}
}