From c7ae064a4cae1ed1b90c51b52f9de19b67afe718 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Thu, 25 Mar 2021 23:55:45 -0300 Subject: [PATCH] Extract ShouldIgnoreCase to Platform --- src/openrct2/core/Path.cpp | 6 +----- src/openrct2/platform/Platform.Posix.cpp | 5 +++++ src/openrct2/platform/Platform.Win32.cpp | 5 +++++ src/openrct2/platform/Platform2.h | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/openrct2/core/Path.cpp b/src/openrct2/core/Path.cpp index e45e1b2e1b..a90be9b6ec 100644 --- a/src/openrct2/core/Path.cpp +++ b/src/openrct2/core/Path.cpp @@ -212,11 +212,7 @@ namespace Path bool Equals(const utf8* a, const utf8* b) { - bool ignoreCase = false; -#ifdef _WIN32 - ignoreCase = true; -#endif - return String::Equals(a, b, ignoreCase); + return String::Equals(a, b, Platform::ShouldIgnoreCase()); } std::string ResolveCasing(const std::string& path) diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index f1ae448934..52fd7149da 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -175,6 +175,11 @@ namespace Platform return lastModified; } + bool ShouldIgnoreCase() + { + return false; + } + bool IsPathSeparator(char c) { return c == '/'; diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index f898911f1b..a1fd9fc8e0 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -554,6 +554,11 @@ namespace Platform return lastModified; } + bool ShouldIgnoreCase() + { + return true; + } + bool IsPathSeparator(char c) { return c == '\\' || c == '/'; diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index 91c159fa05..79c0b3f77a 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -34,6 +34,7 @@ namespace Platform std::string GetDocsPath(); std::string GetCurrentExecutablePath(); std::string GetCurrentExecutableDirectory(); + bool ShouldIgnoreCase(); bool FileExists(const std::string path); bool IsPathSeparator(char c); utf8* GetAbsolutePath(utf8* buffer, size_t bufferSize, const utf8* relativePath);