Add GetUserDir function
This commit is contained in:
@@ -69,24 +69,25 @@ namespace OpenVulkano
|
|||||||
PlatformFolders::PlatformFolders()
|
PlatformFolders::PlatformFolders()
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
userHome = GetHome();
|
||||||
#if TARGET_OS_IOS == 1
|
#if TARGET_OS_IOS == 1
|
||||||
dataHome = GetHome() / "Documents/";
|
dataHome = userHome / "Documents/";
|
||||||
configHome = dataHome;
|
configHome = dataHome;
|
||||||
stateDir = dataHome;
|
stateDir = dataHome;
|
||||||
dataCache = GetHome() / "Library/Caches/";
|
dataCache = userHome / "Library/Caches/";
|
||||||
tempDir = dataCache;
|
tempDir = dataCache;
|
||||||
#else
|
#else
|
||||||
const auto home = GetHome();
|
dataHome = userHome / "Library/Application Support";
|
||||||
dataHome = home / "Library/Application Support";
|
configHome = userHome / "Library/Preferences";
|
||||||
configHome = home / "Library/Preferences";
|
|
||||||
stateDir = dataHome;
|
stateDir = dataHome;
|
||||||
dataCache = home / "Library/Caches";
|
dataCache = userHome / "Library/Caches";
|
||||||
#endif
|
#endif
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
dataHome = GetKnownWindowsFolder(FOLDERID_RoamingAppData, "RoamingAppData");
|
dataHome = GetKnownWindowsFolder(FOLDERID_RoamingAppData, "RoamingAppData");
|
||||||
configHome = GetKnownWindowsFolder(FOLDERID_RoamingAppData, "RoamingAppData");
|
configHome = GetKnownWindowsFolder(FOLDERID_RoamingAppData, "RoamingAppData");
|
||||||
stateDir = GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData");
|
stateDir = GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData");
|
||||||
dataCache = GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData");
|
dataCache = GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData");
|
||||||
|
userHome = GetKnownWindowsFolder(FOLDERID_Profile, "Home");
|
||||||
desktop = GetKnownWindowsFolder(FOLDERID_Desktop, "Desktop");
|
desktop = GetKnownWindowsFolder(FOLDERID_Desktop, "Desktop");
|
||||||
documents = GetKnownWindowsFolder(FOLDERID_Documents, "Documents");
|
documents = GetKnownWindowsFolder(FOLDERID_Documents, "Documents");
|
||||||
downloads = GetKnownWindowsFolder(FOLDERID_Downloads, "Downloads");
|
downloads = GetKnownWindowsFolder(FOLDERID_Downloads, "Downloads");
|
||||||
@@ -100,6 +101,7 @@ namespace OpenVulkano
|
|||||||
configHome = GetXDGFolderDefault("XDG_CONFIG_HOME", ".config");
|
configHome = GetXDGFolderDefault("XDG_CONFIG_HOME", ".config");
|
||||||
stateDir = GetXDGFolderDefault("XDG_STATE_HOME", ".local/state");
|
stateDir = GetXDGFolderDefault("XDG_STATE_HOME", ".local/state");
|
||||||
dataCache = GetXDGFolderDefault("XDG_CACHE_HOME", ".cache");
|
dataCache = GetXDGFolderDefault("XDG_CACHE_HOME", ".cache");
|
||||||
|
userHome = GetHome();
|
||||||
#endif
|
#endif
|
||||||
#if TARGET_OS_IOS != 1
|
#if TARGET_OS_IOS != 1
|
||||||
tempDir = std::filesystem::temp_directory_path();
|
tempDir = std::filesystem::temp_directory_path();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenVulkano
|
|||||||
class PlatformFolders
|
class PlatformFolders
|
||||||
{
|
{
|
||||||
std::filesystem::path dataHome, configHome, stateDir, dataCache, tempDir;
|
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();
|
PlatformFolders();
|
||||||
|
|
||||||
@@ -30,6 +30,8 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
[[nodiscard]] static const std::filesystem::path& GetTempDir() { return GetInstance().tempDir; }
|
[[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& GetDesktopDir() { return GetInstance().desktop; }
|
||||||
|
|
||||||
[[nodiscard]] static const std::filesystem::path& GetDocumentsDir() { return GetInstance().documents; }
|
[[nodiscard]] static const std::filesystem::path& GetDocumentsDir() { return GetInstance().documents; }
|
||||||
|
|||||||
Reference in New Issue
Block a user