Add GetUserDir function

This commit is contained in:
Georg Hagen
2025-06-26 23:37:11 +02:00
parent bbac3f3f47
commit d81d6ddeef
2 changed files with 11 additions and 7 deletions

View File

@@ -69,24 +69,25 @@ namespace OpenVulkano
PlatformFolders::PlatformFolders()
{
#ifdef __APPLE__
userHome = GetHome();
#if TARGET_OS_IOS == 1
dataHome = GetHome() / "Documents/";
dataHome = userHome / "Documents/";
configHome = dataHome;
stateDir = dataHome;
dataCache = GetHome() / "Library/Caches/";
dataCache = userHome / "Library/Caches/";
tempDir = dataCache;
#else
const auto home = GetHome();
dataHome = home / "Library/Application Support";
configHome = home / "Library/Preferences";
dataHome = userHome / "Library/Application Support";
configHome = userHome / "Library/Preferences";
stateDir = dataHome;
dataCache = home / "Library/Caches";
dataCache = userHome / "Library/Caches";
#endif
#elif defined(_WIN32)
dataHome = GetKnownWindowsFolder(FOLDERID_RoamingAppData, "RoamingAppData");
configHome = GetKnownWindowsFolder(FOLDERID_RoamingAppData, "RoamingAppData");
stateDir = GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData");
dataCache = GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData");
userHome = GetKnownWindowsFolder(FOLDERID_Profile, "Home");
desktop = GetKnownWindowsFolder(FOLDERID_Desktop, "Desktop");
documents = GetKnownWindowsFolder(FOLDERID_Documents, "Documents");
downloads = GetKnownWindowsFolder(FOLDERID_Downloads, "Downloads");
@@ -100,6 +101,7 @@ namespace OpenVulkano
configHome = GetXDGFolderDefault("XDG_CONFIG_HOME", ".config");
stateDir = GetXDGFolderDefault("XDG_STATE_HOME", ".local/state");
dataCache = GetXDGFolderDefault("XDG_CACHE_HOME", ".cache");
userHome = GetHome();
#endif
#if TARGET_OS_IOS != 1
tempDir = std::filesystem::temp_directory_path();

View File

@@ -13,7 +13,7 @@ namespace OpenVulkano
class PlatformFolders
{
std::filesystem::path dataHome, configHome, stateDir, dataCache, tempDir;
std::filesystem::path desktop, documents, downloads, pictures, publicDir, music, video, savedGames;
std::filesystem::path userHome, desktop, documents, downloads, pictures, publicDir, music, video, savedGames;
PlatformFolders();
@@ -30,6 +30,8 @@ namespace OpenVulkano
[[nodiscard]] static const std::filesystem::path& GetTempDir() { return GetInstance().tempDir; }
[[nodiscard]] static const std::filesystem::path& GetUserDir() { return GetInstance().userHome; }
[[nodiscard]] static const std::filesystem::path& GetDesktopDir() { return GetInstance().desktop; }
[[nodiscard]] static const std::filesystem::path& GetDocumentsDir() { return GetInstance().documents; }