diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index 0b9df20c0..c8007086e 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -580,7 +580,7 @@ int main(int argc, char** argv) { } SetupBasics(IsClientLoggingEnabled(argc, argv)); - metaforce::FileStoreManager fileMgr{"metaforce"}; + metaforce::FileStoreManager fileMgr{"AxioDL", "metaforce"}; metaforce::CVarManager cvarMgr{fileMgr}; metaforce::CVarCommons cvarCmns{cvarMgr}; diff --git a/Runtime/ConsoleVariables/FileStoreManager.cpp b/Runtime/ConsoleVariables/FileStoreManager.cpp index 167bf4844..98dc08da2 100644 --- a/Runtime/ConsoleVariables/FileStoreManager.cpp +++ b/Runtime/ConsoleVariables/FileStoreManager.cpp @@ -2,6 +2,7 @@ #include "Runtime/CBasics.hpp" +#include #include #if _WIN32 #include @@ -18,46 +19,51 @@ using namespace Windows::Storage; namespace metaforce { 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 !WINDOWS_STORE - WCHAR home[MAX_PATH]; - if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home))) - Log.report(logvisor::Fatal, FMT_STRING("unable to locate profile for file store")); + WCHAR home[MAX_PATH]; + if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home))) + Log.report(logvisor::Fatal, FMT_STRING("unable to locate profile for file store")); - std::string path = nowide::narrow(home); + std::string path = nowide::narrow(home); #else - StorageFolder ^ cacheFolder = ApplicationData::Current->LocalCacheFolder; - std::string path(cacheFolder->Path->Data()); + StorageFolder ^ cacheFolder = ApplicationData::Current->LocalCacheFolder; + std::string path(cacheFolder->Path->Data()); #endif - path += "/.heclrun"; + path += "/." + m_org; - CBasics::MakeDir(path.c_str()); - path += '/'; - path += domain.data(); + CBasics::MakeDir(path.c_str()); + path += '/'; + path += domain.data(); - CBasics::MakeDir(path.c_str()); - m_storeRoot = path; + CBasics::MakeDir(path.c_str()); + m_storeRoot = path; #else - const char* xdg_data_home = getenv("XDG_DATA_HOME"); - std::string path; - if (xdg_data_home) { - if (xdg_data_home[0] != '/') - Log.report(logvisor::Fatal, FMT_STRING("invalid $XDG_DATA_HOME for file store (must be absolute)")); - path = xdg_data_home; + const char* xdg_data_home = getenv("XDG_DATA_HOME"); + std::string path; + if (xdg_data_home) { + if (xdg_data_home[0] != '/') + Log.report(logvisor::Fatal, FMT_STRING("invalid $XDG_DATA_HOME for file store (must be absolute)")); + path = xdg_data_home; + } else { + const char* home = getenv("HOME"); + if (!home) + Log.report(logvisor::Fatal, FMT_STRING("unable to locate $HOME for file store")); + path = home; + path += "/.local/share"; + } + path += "/" + m_org + "/" + domain.data(); + if (CBasics::RecursiveMakeDir(path.c_str()) != 0) { + Log.report(logvisor::Fatal, FMT_STRING("unable to mkdir at {}"), path); + } + m_storeRoot = path; +#endif } else { - const char* home = getenv("HOME"); - if (!home) - Log.report(logvisor::Fatal, FMT_STRING("unable to locate $HOME for file store")); - path = home; - path += "/.local/share"; + m_storeRoot = std::string(prefPath); } - path += "/hecl/"; - path += domain.data(); - if (CBasics::RecursiveMakeDir(path.c_str()) != 0) - Log.report(logvisor::Fatal, FMT_STRING("unable to mkdir at {}"), path); - m_storeRoot = path; -#endif } } // namespace hecl::Runtime diff --git a/Runtime/ConsoleVariables/FileStoreManager.hpp b/Runtime/ConsoleVariables/FileStoreManager.hpp index 20dcf150c..d0e710b21 100644 --- a/Runtime/ConsoleVariables/FileStoreManager.hpp +++ b/Runtime/ConsoleVariables/FileStoreManager.hpp @@ -7,11 +7,13 @@ namespace metaforce { * @brief Per-platform file store resolution */ class FileStoreManager { + std::string m_org; std::string m_domain; std::string m_storeRoot; 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; } /** * @brief Returns the full path to the file store, including domain diff --git a/Runtime/Streams/CTextOutStream.cpp b/Runtime/Streams/CTextOutStream.cpp index 9c69f631b..da6a4b148 100644 --- a/Runtime/Streams/CTextOutStream.cpp +++ b/Runtime/Streams/CTextOutStream.cpp @@ -13,6 +13,7 @@ void CTextOutStream::WriteString(const char* str, u32 len) { } else if (str[i] == '\n' && !wroteCarriageReturn) { m_out->WriteChar('\r'); wroteLineFeed = true; + wroteCarriageReturn = true; } m_out->WriteChar(str[i]); }