#include "Common/Paths.h" #include #include #include #include namespace FEXCore::Paths { std::unique_ptr CachePath; std::unique_ptr EntryCache; void InitializePaths() { CachePath = std::make_unique(); EntryCache = std::make_unique(); char const *HomeDir = getenv("HOME"); if (!HomeDir) { HomeDir = getenv("PWD"); } if (!HomeDir) { HomeDir = "."; } char *XDGDataDir = getenv("XDG_DATA_DIR"); if (XDGDataDir) { *CachePath = XDGDataDir; } else { if (HomeDir) { *CachePath = HomeDir; } } *CachePath += "/.fex-emu/"; *EntryCache = *CachePath + "/EntryCache/"; // Ensure the folder structure is created for our Data if (!std::filesystem::exists(*EntryCache) && !std::filesystem::create_directories(*EntryCache)) { LogMan::Msg::D("Couldn't create EntryCache directory: '%s'", EntryCache->c_str()); } } void ShutdownPaths() { CachePath.reset(); EntryCache.reset(); } std::string GetCachePath() { return *CachePath; } std::string GetEntryCachePath() { return *EntryCache; } }