From 0577497c32b6d274fa92a365ec217f3e376ce7b7 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 26 Jan 2022 14:47:45 +0100 Subject: [PATCH] Remove platform_get_absolute_path() --- src/openrct2/CmdlineSprite.cpp | 3 ++- src/openrct2/platform/Posix.cpp | 25 ------------------------- src/openrct2/platform/Windows.cpp | 27 --------------------------- src/openrct2/platform/platform.h | 1 - 4 files changed, 2 insertions(+), 54 deletions(-) diff --git a/src/openrct2/CmdlineSprite.cpp b/src/openrct2/CmdlineSprite.cpp index 63f9bd2edd..b7a50b1410 100644 --- a/src/openrct2/CmdlineSprite.cpp +++ b/src/openrct2/CmdlineSprite.cpp @@ -14,6 +14,7 @@ #include "core/FileStream.h" #include "core/Imaging.h" #include "core/Json.hpp" +#include "core/Path.hpp" #include "drawing/Drawing.h" #include "drawing/ImageImporter.h" #include "object/ObjectLimits.h" @@ -627,7 +628,7 @@ int32_t cmdline_for_sprite(const char** argv, int32_t argc) bool keep_palette = Json::GetString(jsonSprite["palette"]) == "keep"; bool forceBmp = !jsonSprite["palette"].is_null() && Json::GetBoolean(jsonSprite["forceBmp"]); - auto imagePath = platform_get_absolute_path(strPath.c_str(), directoryPath); + auto imagePath = Path::GetAbsolute(std::string(directoryPath) + "/" + strPath); auto importResult = SpriteImageImport( imagePath.c_str(), Json::GetNumber(x_offset), Json::GetNumber(y_offset), keep_palette, diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 59af5224c2..22207df36e 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -89,31 +89,6 @@ bool platform_ensure_directory_exists(const utf8* path) return true; } -std::string platform_get_absolute_path(const utf8* relative_path, const utf8* base_path) -{ - std::string result; - if (relative_path != nullptr) - { - std::string pathToResolve; - if (base_path == nullptr) - { - pathToResolve = std::string(relative_path); - } - else - { - pathToResolve = std::string(base_path) + std::string("/") + relative_path; - } - - auto realpathResult = realpath(pathToResolve.c_str(), nullptr); - if (realpathResult != nullptr) - { - result = std::string(realpathResult); - free(realpathResult); - } - } - return result; -} - bool platform_lock_single_instance() { char pidFilePath[MAX_PATH]; diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index cd68f1312a..724ad8f724 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -126,33 +126,6 @@ time_t platform_file_get_modified_time(const utf8* path) return 0; } -std::string platform_get_absolute_path(const utf8* relativePath, const utf8* basePath) -{ - std::string result; - if (relativePath != nullptr) - { - std::string pathToResolve; - if (basePath == nullptr) - { - pathToResolve = std::string(relativePath); - } - else - { - pathToResolve = std::string(basePath) + std::string("\\") + relativePath; - } - - auto pathToResolveW = String::ToWideChar(pathToResolve); - wchar_t fullPathW[MAX_PATH]{}; - auto fullPathLen = GetFullPathNameW( - pathToResolveW.c_str(), static_cast(std::size(fullPathW)), fullPathW, nullptr); - if (fullPathLen != 0) - { - result = String::ToUtf8(fullPathW); - } - } - return result; -} - datetime64 platform_get_datetime_now_utc() { // Get file time diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index dee18c31f1..b415a5a158 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -88,7 +88,6 @@ void platform_refresh_video(bool recreate_window); // Platform specific definitions time_t platform_file_get_modified_time(const utf8* path); bool platform_ensure_directory_exists(const utf8* path); -std::string platform_get_absolute_path(const utf8* relative_path, const utf8* base_path); bool platform_lock_single_instance(); // Returns the bitmask of the GetLogicalDrives function for windows, 0 for other systems