25 static std::filesystem::path
get() noexcept {
26 if (
auto homeDir = Env::get<std::filesystem::path>(
"HOME"))
27 if (std::filesystem::exists(*homeDir))
28 return std::move(*homeDir);
30 if (
const auto pw = ::getpwuid(::getuid())) {
31 std::filesystem::path dir = pw->pw_dir;
32 if (std::filesystem::exists(dir))
44 if (
auto xdgCacheDir = Env::get<std::filesystem::path>(
"XDG_CACHE_HOME"))
45 return std::move(*xdgCacheDir);
47 const auto homeDir =
get();
51 return homeDir /
".cache";
59 static std::filesystem::path
createCacheDir(
const std::filesystem::path &subdir) noexcept {
66 std::filesystem::create_directories(cache, ec);
Helpers for $HOME directory.
Definition: HomeDir.h:17
static std::filesystem::path createCacheDir(const std::filesystem::path &subdir) noexcept
Creates (if not existing) and returns getCacheDir() / subdir.
Definition: HomeDir.h:59
static std::filesystem::path getCacheDir() noexcept
Obtains directory for caching.
Definition: HomeDir.h:43