25 static std::filesystem::path
get() noexcept {
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))
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);
static std::filesystem::path getCacheDir() noexcept
Obtains directory for caching.
Definition HomeDir.h:43
static std::filesystem::path get() noexcept
Obtains home directory.
Definition HomeDir.h:25
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::optional< T > get(const std::string &name) noexcept
Get value of name in environment.
Definition Misc.h:98