diff --git a/src/openrct2/core/Path.cpp b/src/openrct2/core/Path.cpp index 8bb3269049..4f8f42fb76 100644 --- a/src/openrct2/core/Path.cpp +++ b/src/openrct2/core/Path.cpp @@ -13,6 +13,7 @@ #endif #include "../localisation/Language.h" +#include "../platform/Platform2.h" #include "../platform/platform.h" #include "../util/Util.h" #include "File.h" @@ -30,15 +31,6 @@ namespace Path return safe_strcat_path(buffer, src, bufferSize); } - static constexpr bool IsPathSeparator(char c) - { -#ifdef _WIN32 - if (c == '\\') - return true; -#endif - return c == '/'; - } - std::string Combine(std::string_view a, std::string_view b) { if (a.empty()) @@ -47,9 +39,9 @@ namespace Path return std::string(a); auto aEnd = a.back(); auto bBegin = b.front(); - if (IsPathSeparator(aEnd)) + if (Platform::IsPathSeparator(aEnd)) { - if (IsPathSeparator(bBegin)) + if (Platform::IsPathSeparator(bBegin)) { return std::string(a) + std::string(b.substr(1)); } @@ -60,7 +52,7 @@ namespace Path } else { - if (IsPathSeparator(bBegin)) + if (Platform::IsPathSeparator(bBegin)) { return std::string(a) + std::string(b); } diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 61e57976b5..fbad60a74e 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -173,6 +173,11 @@ namespace Platform } return lastModified; } + + bool IsPathSeparator(char c) + { + return c == '/'; + } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 1ab0ca0764..cb99189578 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -553,6 +553,12 @@ namespace Platform } return lastModified; } + + bool IsPathSeparator(char c) + { + return c == '\\' || c == '/'; + } + } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index c2b8216298..d09fade07a 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -35,6 +35,7 @@ namespace Platform std::string GetCurrentExecutablePath(); std::string GetCurrentExecutableDirectory(); bool FileExists(const std::string path); + bool IsPathSeparator(char c); uint64_t GetLastModified(const std::string& path); rct2_time GetTimeLocal(); rct2_date GetDateLocal();