1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Remove platform_get_absolute_path()

This commit is contained in:
Gymnasiast
2022-01-26 14:47:45 +01:00
parent 79eca16ad4
commit 0577497c32
4 changed files with 2 additions and 54 deletions

View File

@@ -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<int16_t>(x_offset), Json::GetNumber<int16_t>(y_offset), keep_palette,

View File

@@ -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];

View File

@@ -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<DWORD>(std::size(fullPathW)), fullPathW, nullptr);
if (fullPathLen != 0)
{
result = String::ToUtf8(fullPathW);
}
}
return result;
}
datetime64 platform_get_datetime_now_utc()
{
// Get file time

View File

@@ -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