mirror of https://github.com/OpenRCT2/OpenRCT2.git
Upgrade platform_original_game_data_exists()
This commit is contained in:
parent
ff909cc286
commit
77e5defeca
|
@ -772,7 +772,7 @@ namespace OpenRCT2
|
|||
if (String::IsNullOrEmpty(gCustomRCT2DataPath))
|
||||
{
|
||||
// Check install directory
|
||||
if (gConfigGeneral.rct2_path.empty() || !platform_original_game_data_exists(gConfigGeneral.rct2_path.c_str()))
|
||||
if (gConfigGeneral.rct2_path.empty() || !Platform::OriginalGameDataExists(gConfigGeneral.rct2_path))
|
||||
{
|
||||
log_verbose(
|
||||
"install directory does not exist or invalid directory selected, %s", gConfigGeneral.rct2_path.c_str());
|
||||
|
|
|
@ -695,7 +695,7 @@ namespace Config
|
|||
|
||||
for (const utf8* location : searchLocations)
|
||||
{
|
||||
if (platform_original_game_data_exists(location))
|
||||
if (Platform::OriginalGameDataExists(location))
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
@ -705,20 +705,20 @@ namespace Config
|
|||
if (platform_get_steam_path(steamPath, sizeof(steamPath)))
|
||||
{
|
||||
std::string location = Path::Combine(steamPath, platform_get_rct2_steam_dir());
|
||||
if (platform_original_game_data_exists(location.c_str()))
|
||||
if (Platform::OriginalGameDataExists(location))
|
||||
{
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
auto discordPath = Platform::GetFolderPath(SPECIAL_FOLDER::RCT2_DISCORD);
|
||||
if (!discordPath.empty() && platform_original_game_data_exists(discordPath.c_str()))
|
||||
if (!discordPath.empty() && Platform::OriginalGameDataExists(discordPath))
|
||||
{
|
||||
return discordPath;
|
||||
}
|
||||
|
||||
auto exePath = Path::GetDirectory(Platform::GetCurrentExecutablePath());
|
||||
if (platform_original_game_data_exists(exePath.c_str()))
|
||||
if (Platform::OriginalGameDataExists(exePath))
|
||||
{
|
||||
return exePath;
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ bool config_find_or_browse_install_directory()
|
|||
}
|
||||
gConfigGeneral.rct2_path = installPath;
|
||||
|
||||
if (platform_original_game_data_exists(installPath.c_str()))
|
||||
if (Platform::OriginalGameDataExists(installPath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace Platform
|
|||
bool FindApp(const std::string& app, std::string* output);
|
||||
int32_t Execute(const std::string& command, std::string* output = nullptr);
|
||||
|
||||
bool OriginalGameDataExists(std::string_view path);
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__)
|
||||
std::string GetEnvironmentPath(const char* name);
|
||||
std::string GetHomePath();
|
||||
|
|
|
@ -77,15 +77,6 @@ bool platform_directory_exists(const utf8* path)
|
|||
return result == 0 && S_ISDIR(dirinfo.st_mode);
|
||||
}
|
||||
|
||||
bool platform_original_game_data_exists(const utf8* path)
|
||||
{
|
||||
char checkPath[MAX_PATH];
|
||||
safe_strcpy(checkPath, path, MAX_PATH);
|
||||
safe_strcat_path(checkPath, "Data", MAX_PATH);
|
||||
safe_strcat_path(checkPath, "g1.dat", MAX_PATH);
|
||||
return Platform::FileExists(checkPath);
|
||||
}
|
||||
|
||||
// Implement our own version of getumask(), as it is documented being
|
||||
// "a vaporware GNU extension".
|
||||
static mode_t openrct2_getumask()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "../OpenRCT2.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/FileSystem.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../drawing/LightFX.h"
|
||||
#include "../localisation/Currency.h"
|
||||
|
@ -99,6 +100,12 @@ namespace Platform
|
|||
log_verbose("Checking if file exists: %s", path.c_str());
|
||||
return fs::exists(file);
|
||||
}
|
||||
|
||||
bool OriginalGameDataExists(std::string_view path)
|
||||
{
|
||||
std::string combinedPath = Path::ResolveCasing(Path::Combine(path, "Data", "g1.dat"));
|
||||
return Platform::FileExists(combinedPath);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
using update_palette_func = void (*)(const uint8_t*, int32_t, int32_t);
|
||||
|
|
|
@ -66,15 +66,6 @@ bool platform_directory_exists(const utf8* path)
|
|||
return dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
bool platform_original_game_data_exists(const utf8* path)
|
||||
{
|
||||
utf8 checkPath[MAX_PATH];
|
||||
safe_strcpy(checkPath, path, MAX_PATH);
|
||||
safe_strcat_path(checkPath, "Data", MAX_PATH);
|
||||
safe_strcat_path(checkPath, "g1.dat", MAX_PATH);
|
||||
return Platform::FileExists(checkPath);
|
||||
}
|
||||
|
||||
bool platform_ensure_directory_exists(const utf8* path)
|
||||
{
|
||||
if (platform_directory_exists(path))
|
||||
|
|
|
@ -90,7 +90,6 @@ void platform_get_time_utc(rct2_time* out_time);
|
|||
|
||||
// Platform specific definitions
|
||||
bool platform_directory_exists(const utf8* path);
|
||||
bool platform_original_game_data_exists(const utf8* path);
|
||||
time_t platform_file_get_modified_time(const utf8* path);
|
||||
bool platform_ensure_directory_exists(const utf8* path);
|
||||
bool platform_directory_delete(const utf8* path);
|
||||
|
|
Loading…
Reference in New Issue