diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 4796c9e70d..204089f8f7 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -282,6 +282,13 @@ namespace OpenRCT2 basePaths[(size_t)DIRBASE::USER] = std::string(path); IPlatformEnvironment * env = CreatePlatformEnvironment(basePaths); + + // Log base paths + log_verbose("DIRBASE::RCT1 : %s", env->GetDirectoryPath(DIRBASE::RCT1).c_str()); + log_verbose("DIRBASE::RCT2 : %s", env->GetDirectoryPath(DIRBASE::RCT2).c_str()); + log_verbose("DIRBASE::OPENRCT2: %s", env->GetDirectoryPath(DIRBASE::OPENRCT2).c_str()); + log_verbose("DIRBASE::USER : %s", env->GetDirectoryPath(DIRBASE::USER).c_str()); + return env; } diff --git a/src/openrct2/PlatformEnvironment.cpp b/src/openrct2/PlatformEnvironment.cpp index 3194cfedbe..51920f59fa 100644 --- a/src/openrct2/PlatformEnvironment.cpp +++ b/src/openrct2/PlatformEnvironment.cpp @@ -25,7 +25,7 @@ extern "C" #include "platform/platform.h" } -class PlatformEnvironment : public IPlatformEnvironment +class PlatformEnvironment final : public IPlatformEnvironment { private: std::string _basePath[DIRBASE_COUNT]; @@ -39,9 +39,14 @@ public: } } + std::string GetDirectoryPath(DIRBASE base) const override + { + return _basePath[(size_t)base]; + } + std::string GetDirectoryPath(DIRBASE base, DIRID did) const override { - const utf8 * basePath = _basePath[(size_t)base].c_str(); + auto basePath = GetDirectoryPath(base); const utf8 * directoryName; switch (base) { default: @@ -55,10 +60,7 @@ public: break; } - utf8 path[260]; - String::Set(path, sizeof(path), basePath); - Path::Append(path, sizeof(path), directoryName); - return std::string(path); + return Path::Combine(basePath, directoryName); } std::string GetFilePath(PATHID pathid) const override diff --git a/src/openrct2/PlatformEnvironment.h b/src/openrct2/PlatformEnvironment.h index 0f4683053a..76a28912b6 100644 --- a/src/openrct2/PlatformEnvironment.h +++ b/src/openrct2/PlatformEnvironment.h @@ -68,6 +68,7 @@ interface IPlatformEnvironment { virtual ~IPlatformEnvironment() = default; + virtual std::string GetDirectoryPath(DIRBASE base) const abstract; virtual std::string GetDirectoryPath(DIRBASE base, DIRID did) const abstract; virtual std::string GetFilePath(PATHID pathid) const abstract; };