From 87cd9f88b37b9b35b015d9881dfac2aea2bce2f9 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 1 Dec 2017 23:48:46 +0000 Subject: [PATCH] Rewrite Platform::GetInstallPath --- src/openrct2/Context.cpp | 11 +++ src/openrct2/core/Path.cpp | 11 +++ src/openrct2/core/Path.hpp | 2 + src/openrct2/platform/Android.cpp | 10 --- src/openrct2/platform/Linux.cpp | 66 --------------- src/openrct2/platform/Platform.Android.cpp | 12 +++ src/openrct2/platform/Platform.Linux.cpp | 99 ++++++++++++++++++++++ src/openrct2/platform/Platform.Posix.cpp | 8 -- src/openrct2/platform/Platform.Win32.cpp | 94 ++++++++++++++------ src/openrct2/platform/Platform.macOS.cpp | 56 ++++++++++++ src/openrct2/platform/Platform2.h | 1 + src/openrct2/platform/Posix.cpp | 48 ----------- src/openrct2/platform/Windows.cpp | 55 ------------ src/openrct2/platform/macos.m | 45 ---------- src/openrct2/platform/platform.h | 6 -- 15 files changed, 258 insertions(+), 266 deletions(-) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index b9a15e6f4b..2700e359a1 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1169,4 +1169,15 @@ extern "C" } String::Set(outPath, outSize, path.c_str()); } + + /** + * This function is deprecated. + * Use IPlatformEnvironment instad. + */ + void platform_get_openrct_data_path(utf8 * outPath, size_t outSize) + { + auto env = GetContext()->GetPlatformEnvironment(); + auto path = env->GetDirectoryPath(DIRBASE::OPENRCT2); + String::Set(outPath, outSize, path.c_str()); + } } diff --git a/src/openrct2/core/Path.cpp b/src/openrct2/core/Path.cpp index c58c77e6ac..0ca6056834 100644 --- a/src/openrct2/core/Path.cpp +++ b/src/openrct2/core/Path.cpp @@ -84,6 +84,11 @@ namespace Path platform_ensure_directory_exists(path.c_str()); } + bool DirectoryExists(const std::string &path) + { + return platform_directory_exists(path.c_str()); + } + std::string GetFileName(const std::string &path) { return GetFileName(path.c_str()); @@ -208,6 +213,12 @@ namespace Path #endif } + std::string GetAbsolute(const std::string &relative) + { + utf8 absolute[MAX_PATH]; + return GetAbsolute(absolute, sizeof(absolute), relative.c_str()); + } + bool Equals(const std::string &a, const std::string &b) { return String::Equals(a.c_str(), b.c_str()); diff --git a/src/openrct2/core/Path.hpp b/src/openrct2/core/Path.hpp index e5c4292263..c5986ba2a1 100644 --- a/src/openrct2/core/Path.hpp +++ b/src/openrct2/core/Path.hpp @@ -34,6 +34,7 @@ namespace Path utf8 * GetDirectory(const utf8 * path); utf8 * GetDirectory(utf8 * buffer, size_t bufferSize, const utf8 * path); void CreateDirectory(const std::string &path); + bool DirectoryExists(const std::string &path); std::string GetFileName(const std::string &path); const utf8 * GetFileName(const utf8 * path); std::string GetFileNameWithoutExtension(const std::string &path); @@ -42,6 +43,7 @@ namespace Path const std::string GetExtension(const std::string &path); const utf8 * GetExtension(const utf8 * path); utf8 * GetAbsolute(utf8 * buffer, size_t bufferSize, const utf8 * relativePath); + std::string GetAbsolute(const std::string &relative); bool Equals(const std::string &a, const std::string &b); bool Equals(const utf8 * a, const utf8 * b); diff --git a/src/openrct2/platform/Android.cpp b/src/openrct2/platform/Android.cpp index a80b562a08..9a25862d07 100644 --- a/src/openrct2/platform/Android.cpp +++ b/src/openrct2/platform/Android.cpp @@ -24,11 +24,6 @@ #include #include -void platform_get_exe_path(utf8 *outPath, size_t outSize) -{ - safe_strcpy(outPath, "/sdcard/openrct2", outSize); -} - #ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) { @@ -37,11 +32,6 @@ bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) } #endif -void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size) { - safe_strcpy(out, "/sdcard/openrct2", size); -} - - uint16 platform_get_locale_language() { return LANGUAGE_ENGLISH_UK; } diff --git a/src/openrct2/platform/Linux.cpp b/src/openrct2/platform/Linux.cpp index 00e3024860..4d751858c4 100644 --- a/src/openrct2/platform/Linux.cpp +++ b/src/openrct2/platform/Linux.cpp @@ -42,72 +42,6 @@ #include "../util/Util.h" #include "platform.h" -void platform_get_exe_path(utf8 *outPath, size_t outSize) -{ - char exePath[MAX_PATH]; -#ifdef __linux__ - ssize_t bytesRead; - bytesRead = readlink("/proc/self/exe", exePath, MAX_PATH); - if (bytesRead == -1) { - log_fatal("failed to read /proc/self/exe"); - } - exePath[bytesRead - 1] = '\0'; -#elif defined(__FreeBSD__) - size_t exeLen = sizeof(exePath); - const sint32 mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; - if (sysctl(mib, 4, exePath, &exeLen, NULL, 0) == -1) { - log_fatal("failed to get process path"); - - } -#elif defined(__OpenBSD__) - // There is no way to get the path name of a running executable. - // If you are not using the port or package, you may have to change this line! - strlcpy(exePath, "/usr/local/bin/", sizeof(exePath)); -#else -#error "Platform does not support full path exe retrieval" -#endif - char *exeDelimiter = strrchr(exePath, *PATH_SEPARATOR); - if (exeDelimiter == nullptr) - { - log_error("should never happen here"); - outPath[0] = '\0'; - return; - } - *exeDelimiter = '\0'; - - safe_strcpy(outPath, exePath, outSize); -} - -/** - * Default directory fallback is: - * - (command line argument) - * - /data - * - /usr/local/share/openrct2 - * - /var/lib/openrct2 - * - /usr/share/openrct2 - */ -void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size) { - static const utf8 *searchLocations[] = { - "../share/openrct2", -#ifdef ORCT2_RESOURCE_DIR - // defined in CMakeLists.txt - ORCT2_RESOURCE_DIR, -#endif // ORCT2_RESOURCE_DIR - "/usr/local/share/openrct2", - "/var/lib/openrct2", - "/usr/share/openrct2", - }; - for (auto searchLocation : searchLocations) - { - log_verbose("Looking for OpenRCT2 data in %s", searchLocation); - if (platform_directory_exists(searchLocation)) - { - safe_strcpy(out, searchLocation, size); - return; - } - } -} - uint16 platform_get_locale_language(){ const char *langString = setlocale(LC_MESSAGES, ""); if(langString != nullptr){ diff --git a/src/openrct2/platform/Platform.Android.cpp b/src/openrct2/platform/Platform.Android.cpp index bdabd83035..8262a55007 100644 --- a/src/openrct2/platform/Platform.Android.cpp +++ b/src/openrct2/platform/Platform.Android.cpp @@ -16,6 +16,7 @@ #ifdef __ANDROID__ +#include #include "Platform2.h" namespace Platform @@ -39,6 +40,17 @@ namespace Platform { return std::string(); } + + std::string GetInstallPath() + { + return "/sdcard/openrct2"; + } + + std::string GetCurrentExecutablePath() + { + assert(false, "GetCurrentExecutablePath() not implemented for Android."); + return std::string(); + } } #endif diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp index 9db7b69b65..0f98e1b2e5 100644 --- a/src/openrct2/platform/Platform.Linux.cpp +++ b/src/openrct2/platform/Platform.Linux.cpp @@ -16,8 +16,11 @@ #if defined(__linux__) && !defined(__ANDROID__) +#include #include #include "../core/Path.hpp" +#include "../core/Util.hpp" +#include "../OpenRCT2.h" #include "platform.h" #include "Platform2.h" @@ -63,6 +66,102 @@ namespace Platform } return std::string(); } + + static std::string FindInstallPath() + { + static const char * SearchLocations[] = + { + "../share/openrct2", +#ifdef ORCT2_RESOURCE_DIR + // defined in CMakeLists.txt + ORCT2_RESOURCE_DIR, +#endif // ORCT2_RESOURCE_DIR + "/usr/local/share/openrct2", + "/var/lib/openrct2", + "/usr/share/openrct2", + }; + for (auto searchLocation : SearchLocations) + { + log_verbose("Looking for OpenRCT2 data in %s", searchLocation); + if (Path::DirectoryExists(searchLocation)) + { + return searchLocation; + } + } + return std::string(); + } + + static std::string GetCurrentWorkingDirectory() + { + char cwdPath[PATH_MAX]; + if (getcwd(cwdPath, sizeof(cwdPath)) != nullptr) + { + return cwdPath; + } + return std::string(); + } + + std::string GetInstallPath() + { + // 1. Try command line argument + auto path = std::string(gCustomOpenrctDataPath); + if (!path.empty()) + { + path = Path::GetAbsolute(path); + } + else + { + // 2. Try ${exeDir}/data + auto exePath = Platform::GetCurrentExecutablePath(); + auto exeDirectory = Path::GetDirectory(exePath); + path = Path::Combine(exeDirectory, "data"); + if (!Path::DirectoryExists(path)) + { + // 3. Try standard system app directories + path = FindInstallPath(); + if (path.empty()) + { + // 4. Fallback to ${cwd}/data + path = GetCurrentWorkingDirectory(); + if (!path.empty()) + { + path = Path::Combine(path, "data"); + } + else + { + return "/"; + } + } + } + } + return path; + } + + std::string GetCurrentExecutablePath() + { + char exePath[PATH_MAX] = { 0 }; +#ifdef __linux__ + auto bytesRead = readlink("/proc/self/exe", exePath, sizeof(exePath)); + if (bytesRead == -1) + { + log_fatal("failed to read /proc/self/exe"); + } +#elif defined(__FreeBSD__) + const sint32 mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + auto exeLen = sizeof(exePath); + if (sysctl(mib, 4, exePath, &exeLen, nullptr, 0) == -1) + { + log_fatal("failed to get process path"); + } +#elif defined(__OpenBSD__) + // There is no way to get the path name of a running executable. + // If you are not using the port or package, you may have to change this line! + strlcpy(exePath, "/usr/local/bin/", sizeof(exePath)); +#else + #error "Platform does not support full path exe retrieval" +#endif + return exePath; + } } #endif diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index caa4a65839..038406cdb4 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -76,14 +76,6 @@ namespace Platform return path; } - std::string GetInstallPath() - { - utf8 path[MAX_PATH]; - platform_resolve_openrct_data_path(); - platform_get_openrct_data_path(path, sizeof(path)); - return path; - } - std::string FormatShortDate(std::time_t timestamp) { char date[20]; diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 048f8170bb..4dd9559b1a 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -16,6 +16,8 @@ #ifdef _WIN32 +#include + #define WIN32_LEAN_AND_MEAN #include #include @@ -30,11 +32,19 @@ #include "../core/Path.hpp" #include "../core/String.hpp" #include "../core/Util.hpp" +#include "../OpenRCT2.h" #include "Platform2.h" #include "platform.h" namespace Platform { +#ifdef __USE_SHGETKNOWNFOLDERPATH__ + static std::string WIN32_GetKnownFolderPath(REFKNOWNFOLDERID rfid); +#else + static std::string WIN32_GetFolderPath(int nFolder); +#endif + static std::string WIN32_GetModuleFileNameW(HMODULE hModule); + uint32 GetTicks() { return platform_get_ticks(); @@ -72,31 +82,6 @@ namespace Platform return result; } -#ifdef __USE_SHGETKNOWNFOLDERPATH__ - static std::string WIN32_GetKnownFolderPath(REFKNOWNFOLDERID rfid) - { - std::string path; - wchar_t * wpath = nullptr; - if (SUCCEEDED(SHGetKnownFolderPath(rfid, KF_FLAG_CREATE, nullptr, &wpath))) - { - path = String::ToUtf8(std::wstring(wpath)); - } - CoTaskMemFree(wpath); - return path; - } -#else - static std::string WIN32_GetFolderPath(int nFolder) - { - std::string path; - wchar_t wpath[MAX_PATH]; - if (SUCCEEDED(SHGetFolderPathW(nullptr, nFolder | CSIDL_FLAG_CREATE, nullptr, 0, wpath))) - { - path = String::ToUtf8(std::wstring(wpath)); - } - return path; - } -#endif - std::string GetFolderPath(SPECIAL_FOLDER folder) { switch (folder) @@ -141,12 +126,25 @@ namespace Platform std::string GetInstallPath() { - utf8 path[MAX_PATH]; - platform_resolve_openrct_data_path(); - platform_get_openrct_data_path(path, sizeof(path)); + auto path = std::string(gCustomOpenrctDataPath); + if (!path.empty()) + { + path = Path::GetAbsolute(path); + } + else + { + auto exePath = GetCurrentExecutablePath(); + auto exeDirectory = Path::GetDirectory(exePath); + path = Path::Combine(exeDirectory, "data"); + } return path; } + std::string GetCurrentExecutablePath() + { + return WIN32_GetModuleFileNameW(nullptr); + } + std::string GetDocsPath() { return std::string(); @@ -198,6 +196,46 @@ namespace Platform return result; } + +#ifdef __USE_SHGETKNOWNFOLDERPATH__ + static std::string WIN32_GetKnownFolderPath(REFKNOWNFOLDERID rfid) + { + std::string path; + wchar_t * wpath = nullptr; + if (SUCCEEDED(SHGetKnownFolderPath(rfid, KF_FLAG_CREATE, nullptr, &wpath))) + { + path = String::ToUtf8(std::wstring(wpath)); + } + CoTaskMemFree(wpath); + return path; + } +#else + static std::string WIN32_GetFolderPath(int nFolder) + { + std::string path; + wchar_t wpath[MAX_PATH]; + if (SUCCEEDED(SHGetFolderPathW(nullptr, nFolder | CSIDL_FLAG_CREATE, nullptr, 0, wpath))) + { + path = String::ToUtf8(std::wstring(wpath)); + } + return path; + } +#endif + + static std::string WIN32_GetModuleFileNameW(HMODULE hModule) + { + uint32 wExePathCapacity = MAX_PATH; + std::unique_ptr wExePath; + uint32 size; + do + { + wExePathCapacity *= 2; + wExePath = std::make_unique(wExePathCapacity); + size = GetModuleFileNameW(hModule, wExePath.get(), wExePathCapacity); + } + while (size >= wExePathCapacity); + return String::ToUtf8(wExePath.get()); + } } #endif diff --git a/src/openrct2/platform/Platform.macOS.cpp b/src/openrct2/platform/Platform.macOS.cpp index d82b28dc2f..35aaaebf1a 100644 --- a/src/openrct2/platform/Platform.macOS.cpp +++ b/src/openrct2/platform/Platform.macOS.cpp @@ -44,6 +44,62 @@ namespace Platform { return std::string(); } + + std::string GetInstallPath() + { + auto path = std::string(gCustomOpenrctDataPath); + if (!path.empty()) + { + path = Path::GetAbsolute(customPath); + } + else + { + auto exePath = GetCurrentExecutablePath(); + auto exeDirectory = Path::GetDirectory(exePath); + path = Path::Combine(exeDirectory, "data"); + if (!Directory::Exists(path)) + { + path = GetBundlePath(); + if (path.empty()) + { + path = "/"; + } + } + } + return path; + } + + std::string GetCurrentExecutablePath() + { + char exePath[MAX_PATH]; + uint32 size = MAX_PATH; + int result = _NSGetExecutablePath(exePath, &size); + if (result == 0) + { + return exePath; + } + else + { + return std::string(); + } + } + + static std::string GetBundlePath() + { + @autoreleasepool + { + NSBundle * bundle = [NSBundle mainBundle]; + if (bundle) + { + auto resources = bundle.resourcePath.UTF8String; + if (Path::DirectoryExists(resources)) + { + return resources; + } + } + return std::string(); + } + } } #endif diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index 38cdcefa77..45d71b158b 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -37,6 +37,7 @@ namespace Platform std::string GetFolderPath(SPECIAL_FOLDER folder); std::string GetInstallPath(); std::string GetDocsPath(); + std::string GetCurrentExecutablePath(); #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) std::string GetEnvironmentPath(const char * name); diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 0b80c82ecc..ace051e46b 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -48,7 +48,6 @@ extern "C" { static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 }; -static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; void platform_get_date_utc(rct2_date *out_date) { @@ -400,53 +399,6 @@ static wchar_t *regular_to_wchar(const char* src) return w_buffer; } -void platform_get_openrct_data_path(utf8 *outPath, size_t outSize) -{ - safe_strcpy(outPath, _openrctDataDirectoryPath, outSize); -} - -/** - * Default directory fallback is: - * - (command line argument) - * - /data - * - - */ -void platform_resolve_openrct_data_path() -{ - if (gCustomOpenrctDataPath[0] != 0) { - // NOTE: second argument to `realpath` is meant to either be NULL or `PATH_MAX`-sized buffer, - // since our `MAX_PATH` macro is set to some other value, pass NULL to have `realpath` return - // a `malloc`ed buffer. - char *resolved_path = realpath(gCustomOpenrctDataPath, NULL); - if (resolved_path == nullptr) { - log_error("Could not resolve path \"%s\", errno = %d", gCustomOpenrctDataPath, errno); - return; - } else { - safe_strcpy(_openrctDataDirectoryPath, resolved_path, MAX_PATH); - free(resolved_path); - } - - path_end_with_separator(_openrctDataDirectoryPath, MAX_PATH); - return; - } - - char buffer[MAX_PATH]; - platform_get_exe_path(buffer, sizeof(buffer)); - - safe_strcat_path(buffer, "data", MAX_PATH); - log_verbose("Looking for OpenRCT2 data in %s", buffer); - if (platform_directory_exists(buffer)) - { - _openrctDataDirectoryPath[0] = '\0'; - safe_strcpy(_openrctDataDirectoryPath, buffer, MAX_PATH); - log_verbose("Found OpenRCT2 data in %s", _openrctDataDirectoryPath); - return; - } - - platform_posix_sub_resolve_openrct_data_path(_openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath)); - log_verbose("Trying to use OpenRCT2 data in %s", _openrctDataDirectoryPath); -} - time_t platform_file_get_modified_time(const utf8* path){ struct stat buf; if (stat(path, &buf) == 0) { diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 1a20891c94..68f790f798 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -53,8 +53,6 @@ extern "C" { -static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 }; - #define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" static HMODULE _dllModule = nullptr; @@ -205,45 +203,6 @@ bool platform_file_delete(const utf8 *path) return success == TRUE; } -void platform_resolve_openrct_data_path() -{ - wchar_t wOutPath[MAX_PATH]; - - if (gCustomOpenrctDataPath[0] != 0) { - wchar_t *customOpenrctDataPathW = utf8_to_widechar(gCustomOpenrctDataPath); - if (GetFullPathNameW(customOpenrctDataPathW, (DWORD)Util::CountOf(wOutPath), wOutPath, NULL) == 0) { - log_fatal("Unable to resolve path '%s'.", gCustomOpenrctDataPath); - exit(-1); - } - utf8 *outPathTemp = widechar_to_utf8(wOutPath); - safe_strcpy(_openrctDataDirectoryPath, outPathTemp, sizeof(_openrctDataDirectoryPath)); - free(outPathTemp); - free(customOpenrctDataPathW); - - path_end_with_separator(_openrctDataDirectoryPath, sizeof(_openrctDataDirectoryPath)); - return; - } - char buffer[MAX_PATH]; - platform_get_exe_path(buffer, sizeof(buffer)); - - safe_strcat_path(buffer, "data", MAX_PATH); - - if (platform_directory_exists(buffer)) - { - _openrctDataDirectoryPath[0] = '\0'; - safe_strcpy(_openrctDataDirectoryPath, buffer, sizeof(_openrctDataDirectoryPath)); - return; - } else { - log_fatal("Unable to resolve openrct data path."); - exit(-1); - } -} - -void platform_get_openrct_data_path(utf8 *outPath, size_t outSize) -{ - safe_strcpy(outPath, _openrctDataDirectoryPath, outSize); -} - bool platform_get_steam_path(utf8 * outPath, size_t outSize) { wchar_t * wSteamPath; @@ -488,20 +447,6 @@ uint8 platform_get_locale_date_format() return DATE_FORMAT_DAY_MONTH_YEAR; } -void platform_get_exe_path(utf8 *outPath, size_t outSize) -{ - wchar_t exePath[MAX_PATH]; - wchar_t tempPath[MAX_PATH]; - wchar_t *exeDelimiter; - - GetModuleFileNameW(NULL, exePath, MAX_PATH); - exeDelimiter = wcsrchr(exePath, *PATH_SEPARATOR); - *exeDelimiter = L'\0'; - wcscpy_s(tempPath, MAX_PATH, exePath); - _wfullpath(exePath, tempPath, MAX_PATH); - WideCharToMultiByte(CP_UTF8, 0, exePath, MAX_PATH, outPath, (sint32) outSize, NULL, NULL); -} - bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size) { #if !defined(__MINGW32__) && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) diff --git a/src/openrct2/platform/macos.m b/src/openrct2/platform/macos.m index cb29c7ca9f..ddf58ec298 100644 --- a/src/openrct2/platform/macos.m +++ b/src/openrct2/platform/macos.m @@ -34,51 +34,6 @@ void macos_disallow_automatic_window_tabbing() } } -void platform_get_exe_path(utf8 *outPath, size_t outSize) -{ - if (outSize == 0) return; - char exePath[MAX_PATH]; - uint32_t size = MAX_PATH; - int result = _NSGetExecutablePath(exePath, &size); - if (result != 0) { - log_fatal("failed to get path"); - } - exePath[MAX_PATH - 1] = '\0'; - char *exeDelimiter = strrchr(exePath, *PATH_SEPARATOR); - if (exeDelimiter == NULL) - { - log_error("should never happen here"); - outPath[0] = '\0'; - return; - } - *exeDelimiter = '\0'; - - safe_strcpy(outPath, exePath, outSize); -} - -/** - * Default directory fallback is: - * - (command line argument) - * - /data - * - - */ -void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size) { - @autoreleasepool - { - NSBundle *bundle = [NSBundle mainBundle]; - if (bundle) - { - const utf8 *resources = bundle.resourcePath.UTF8String; - if (platform_directory_exists(resources)) - { - out[0] = '\0'; - safe_strcpy(out, resources, size); - return; - } - } - } -} - utf8* macos_str_decomp_to_precomp(utf8 *input) { @autoreleasepool diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index a761d9454a..53e7ebf163 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -95,7 +95,6 @@ void platform_get_date_local(rct2_date *out_date); void platform_get_time_local(rct2_time *out_time); // Platform specific definitions -void platform_get_exe_path(utf8 *outPath, size_t outSize); bool platform_file_exists(const utf8 *path); bool platform_directory_exists(const utf8 *path); bool platform_original_game_data_exists(const utf8 *path); @@ -114,7 +113,6 @@ bool platform_file_move(const utf8 *srcPath, const utf8 *dstPath); bool platform_file_delete(const utf8 *path); uint32 platform_get_ticks(); void platform_sleep(uint32 ms); -void platform_resolve_openrct_data_path(); void platform_get_openrct_data_path(utf8 *outPath, size_t outSize); void platform_get_user_directory(utf8 *outPath, const utf8 *subDirectory, size_t outSize); utf8* platform_get_username(); @@ -162,10 +160,6 @@ void core_init(); __declspec(dllexport) sint32 StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, sint32 nCmdShow); #endif // _WIN32 -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__ANDROID__) - void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size); -#endif - #if defined(__APPLE__) && defined(__MACH__) void macos_disallow_automatic_window_tabbing(); utf8* macos_str_decomp_to_precomp(utf8 *input);