mirror of https://github.com/AxioDL/metaforce.git
FileStoreManager: Use SDL_GetPrefPath, add org argument
Use SDL_GetPrefPath by default, if we fail to get a valid path *then* we use the platform specific logic as a fallback
This commit is contained in:
parent
399b44baf0
commit
b305454199
|
@ -580,7 +580,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupBasics(IsClientLoggingEnabled(argc, argv));
|
SetupBasics(IsClientLoggingEnabled(argc, argv));
|
||||||
metaforce::FileStoreManager fileMgr{"metaforce"};
|
metaforce::FileStoreManager fileMgr{"AxioDL", "metaforce"};
|
||||||
metaforce::CVarManager cvarMgr{fileMgr};
|
metaforce::CVarManager cvarMgr{fileMgr};
|
||||||
metaforce::CVarCommons cvarCmns{cvarMgr};
|
metaforce::CVarCommons cvarCmns{cvarMgr};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Runtime/CBasics.hpp"
|
#include "Runtime/CBasics.hpp"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
#include <logvisor/logvisor.hpp>
|
#include <logvisor/logvisor.hpp>
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#include <nowide/convert.hpp>
|
#include <nowide/convert.hpp>
|
||||||
|
@ -18,7 +19,9 @@ using namespace Windows::Storage;
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
static logvisor::Module Log("FileStoreManager");
|
static logvisor::Module Log("FileStoreManager");
|
||||||
|
|
||||||
FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
|
FileStoreManager::FileStoreManager(std::string_view org, std::string_view domain) : m_org(org), m_domain(domain) {
|
||||||
|
auto prefPath = SDL_GetPrefPath(org.data(), domain.data());
|
||||||
|
if (prefPath == nullptr) {
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
WCHAR home[MAX_PATH];
|
WCHAR home[MAX_PATH];
|
||||||
|
@ -30,7 +33,7 @@ FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
|
||||||
StorageFolder ^ cacheFolder = ApplicationData::Current->LocalCacheFolder;
|
StorageFolder ^ cacheFolder = ApplicationData::Current->LocalCacheFolder;
|
||||||
std::string path(cacheFolder->Path->Data());
|
std::string path(cacheFolder->Path->Data());
|
||||||
#endif
|
#endif
|
||||||
path += "/.heclrun";
|
path += "/." + m_org;
|
||||||
|
|
||||||
CBasics::MakeDir(path.c_str());
|
CBasics::MakeDir(path.c_str());
|
||||||
path += '/';
|
path += '/';
|
||||||
|
@ -52,12 +55,15 @@ FileStoreManager::FileStoreManager(std::string_view domain) : m_domain(domain) {
|
||||||
path = home;
|
path = home;
|
||||||
path += "/.local/share";
|
path += "/.local/share";
|
||||||
}
|
}
|
||||||
path += "/hecl/";
|
path += "/" + m_org + "/" + domain.data();
|
||||||
path += domain.data();
|
if (CBasics::RecursiveMakeDir(path.c_str()) != 0) {
|
||||||
if (CBasics::RecursiveMakeDir(path.c_str()) != 0)
|
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("unable to mkdir at {}"), path);
|
Log.report(logvisor::Fatal, FMT_STRING("unable to mkdir at {}"), path);
|
||||||
|
}
|
||||||
m_storeRoot = path;
|
m_storeRoot = path;
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
m_storeRoot = std::string(prefPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace hecl::Runtime
|
} // namespace hecl::Runtime
|
||||||
|
|
|
@ -7,11 +7,13 @@ namespace metaforce {
|
||||||
* @brief Per-platform file store resolution
|
* @brief Per-platform file store resolution
|
||||||
*/
|
*/
|
||||||
class FileStoreManager {
|
class FileStoreManager {
|
||||||
|
std::string m_org;
|
||||||
std::string m_domain;
|
std::string m_domain;
|
||||||
std::string m_storeRoot;
|
std::string m_storeRoot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileStoreManager(std::string_view domain);
|
FileStoreManager(std::string_view org, std::string_view domain);
|
||||||
|
std::string_view getOrg() const { return m_org; }
|
||||||
std::string_view getDomain() const { return m_domain; }
|
std::string_view getDomain() const { return m_domain; }
|
||||||
/**
|
/**
|
||||||
* @brief Returns the full path to the file store, including domain
|
* @brief Returns the full path to the file store, including domain
|
||||||
|
|
|
@ -13,6 +13,7 @@ void CTextOutStream::WriteString(const char* str, u32 len) {
|
||||||
} else if (str[i] == '\n' && !wroteCarriageReturn) {
|
} else if (str[i] == '\n' && !wroteCarriageReturn) {
|
||||||
m_out->WriteChar('\r');
|
m_out->WriteChar('\r');
|
||||||
wroteLineFeed = true;
|
wroteLineFeed = true;
|
||||||
|
wroteCarriageReturn = true;
|
||||||
}
|
}
|
||||||
m_out->WriteChar(str[i]);
|
m_out->WriteChar(str[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue