From bbc389d18e9f6c60b60daf7f8f270e9f83afe3c1 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 29 Nov 2017 18:05:51 +0000 Subject: [PATCH] Fix remaining code issues --- src/openrct2/platform/Platform2.cpp | 21 ++++++++++++++++++--- src/openrct2/platform/macos.m | 20 -------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/openrct2/platform/Platform2.cpp b/src/openrct2/platform/Platform2.cpp index 974c12745a..988d45ee00 100644 --- a/src/openrct2/platform/Platform2.cpp +++ b/src/openrct2/platform/Platform2.cpp @@ -171,7 +171,7 @@ namespace Platform return path; } #elif defined (__ANDROID__) - // Andorid builds currently only read from /sdcard/openrct2* + // Android builds currently only read from /sdcard/openrct2* case SPECIAL_FOLDER::USER_CACHE: case SPECIAL_FOLDER::USER_CONFIG: case SPECIAL_FOLDER::USER_DATA: @@ -185,7 +185,7 @@ namespace Platform case SPECIAL_FOLDER::USER_HOME: { auto home = GetFolderPath(SPECIAL_FOLDER::USER_HOME); - return Path::Combine(home, "/Library/Application Support"); + return Path::Combine(home, "Library/Application Support"); } #else case SPECIAL_FOLDER::USER_CACHE: @@ -219,7 +219,22 @@ namespace Platform return path; } case SPECIAL_FOLDER::USER_HOME: - return getpwuid(getuid())->pw_dir; + { + std::string path; + auto pw = getpwuid(getuid()); + if (pw != nullptr) + { + path = pw->pw_dir; + } + else + { + path = GetHomePathViaEnvironment(); + } + if (path.empty()) + { + return "/"; + } + } #endif default: return std::string(); diff --git a/src/openrct2/platform/macos.m b/src/openrct2/platform/macos.m index b439b81463..d5fa987273 100644 --- a/src/openrct2/platform/macos.m +++ b/src/openrct2/platform/macos.m @@ -56,26 +56,6 @@ void platform_get_exe_path(utf8 *outPath, size_t outSize) safe_strcpy(outPath, exePath, outSize); } -/** - * Default directory fallback is: - * - (command line argument) - * - ~/Library/Application Support/OpenRCT2 - */ -void platform_posix_sub_user_data_path(char *buffer, size_t size, const char *homedir) { - if (homedir == NULL) - { - log_fatal("Couldn't find user data directory"); - exit(-1); - return; - } - - safe_strcpy(buffer, homedir, size); - safe_strcat_path(buffer, "Library", size); - safe_strcat_path(buffer, "Application Support", size); - safe_strcat_path(buffer, "OpenRCT2", size); - path_end_with_separator(buffer, size); -} - /** * Default directory fallback is: * - (command line argument)