Hey guys, just looking for hints as to avoiding needing to put this value in a variable to call close()
pub fn getXdgConfigHomeDir() !?std.fs.Dir {
return try std.fs.openDirAbsolute(std.posix.getenv("XDG_CONFIG_HOME") orelse {
return null;
}, .{ .iterate = true });
}
// ...
if (try environment.getXdgConfigHomeDir()) |home_dir| {
const path = try std.fs.path.join(
alloc,
&.{ "zfe", "config.json" },
);
if (environment.fileExists(home_dir, path)) {
break :lbl .{
.home_dir = home_dir,
.path = path,
};
}
alloc.free(path);
// TODO(18-12-24): Hack to call `.close()` as `home_dir` is a
// constant.
var dir = home_dir;
dir.close();
}
src/config.zig:31:25: error: expected type '*fs.Dir', found '*const fs.Dir'
home_dir.close();