diff --git a/src/openrct2/core/Path.cpp b/src/openrct2/core/Path.cpp index 02d68727de..05532aa139 100644 --- a/src/openrct2/core/Path.cpp +++ b/src/openrct2/core/Path.cpp @@ -86,8 +86,8 @@ namespace Path std::string GetAbsolute(std::string_view relative) { - utf8 absolute[MAX_PATH]; - return Platform::GetAbsolutePath(absolute, sizeof(absolute), std::string(relative).c_str()); + std::error_code ec; + return fs::absolute(u8path(relative), ec).u8string(); } bool Equals(std::string_view a, std::string_view b) diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 0fc76a2ab6..7108b2a2c4 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -203,19 +203,6 @@ namespace Platform return c == '/'; } - utf8* GetAbsolutePath(utf8* buffer, size_t bufferSize, const utf8* relativePath) - { - utf8* absolutePath = realpath(relativePath, nullptr); - if (absolutePath == nullptr) - { - return String::Set(buffer, bufferSize, relativePath); - } - - String::Set(buffer, bufferSize, absolutePath); - Memory::Free(absolutePath); - return buffer; - } - std::string ResolveCasing(std::string_view path, bool fileExists) { std::string result; diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 96e12986c2..07491ac668 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -585,22 +585,6 @@ namespace Platform return c == '\\' || c == '/'; } - utf8* GetAbsolutePath(utf8* buffer, size_t bufferSize, const utf8* relativePath) - { - auto relativePathW = String::ToWideChar(relativePath); - wchar_t absolutePathW[MAX_PATH]; - DWORD length = GetFullPathNameW( - relativePathW.c_str(), static_cast(std::size(absolutePathW)), absolutePathW, nullptr); - if (length == 0) - { - return String::Set(buffer, bufferSize, relativePath); - } - - auto absolutePath = String::ToUtf8(absolutePathW); - String::Set(buffer, bufferSize, absolutePath.c_str()); - return buffer; - } - std::string ResolveCasing(std::string_view path, bool fileExists) { std::string result; diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index 7225215d36..fbcf0e2469 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -36,7 +36,6 @@ namespace Platform std::string GetCurrentExecutableDirectory(); bool ShouldIgnoreCase(); bool IsPathSeparator(char c); - utf8* GetAbsolutePath(utf8* buffer, size_t bufferSize, const utf8* relativePath); uint64_t GetLastModified(std::string_view path); uint64_t GetFileSize(std::string_view path); std::string ResolveCasing(std::string_view path, bool fileExists);