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

Fix Android

This commit is contained in:
Gymnasiast
2022-01-08 15:42:27 +01:00
parent 919c73d030
commit 10301507a9
11 changed files with 20 additions and 13 deletions

View File

@@ -194,7 +194,7 @@ void ShortcutManager::LoadUserBindings()
{
try
{
auto path = fs::u8path(_env->GetFilePath(PATHID::CONFIG_SHORTCUTS));
auto path = u8path(_env->GetFilePath(PATHID::CONFIG_SHORTCUTS));
if (fs::exists(path))
{
LoadUserBindings(path);
@@ -204,7 +204,7 @@ void ShortcutManager::LoadUserBindings()
try
{
Console::WriteLine("Importing legacy shortcuts...");
auto legacyPath = fs::u8path(_env->GetFilePath(PATHID::CONFIG_SHORTCUTS_LEGACY));
auto legacyPath = u8path(_env->GetFilePath(PATHID::CONFIG_SHORTCUTS_LEGACY));
if (fs::exists(legacyPath))
{
LoadLegacyBindings(legacyPath);
@@ -315,7 +315,7 @@ void ShortcutManager::SaveUserBindings()
{
try
{
auto path = fs::u8path(_env->GetFilePath(PATHID::CONFIG_SHORTCUTS));
auto path = u8path(_env->GetFilePath(PATHID::CONFIG_SHORTCUTS));
SaveUserBindings(path);
}
catch (const std::exception& e)

View File

@@ -583,7 +583,7 @@ namespace OpenRCT2
{
if (String::Equals(Path::GetExtension(path), ".sea", true))
{
auto data = DecryptSea(fs::u8path(path));
auto data = DecryptSea(u8path(path));
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
if (!LoadParkFromStream(&ms, path, loadTitleScreenOnFail, asScenario))
{

View File

@@ -110,7 +110,7 @@ namespace OpenRCT2
_fileSize = _filelengthi64(_fileno(_file));
#else
std::error_code ec;
_fileSize = fs::file_size(fs::u8path(path), ec);
_fileSize = fs::file_size(u8path(path), ec);
#endif
_ownsFilePtr = true;

View File

@@ -57,3 +57,9 @@ namespace fs = ghc::filesystem;
#endif
#undef HAVE_STD_FILESYSTEM // Not needed any more, don't make it public.
#ifdef __ANDROID__
# define u8path(path) fs::u8path(std::string(path))
#else
# define u8path(path) fs::u8path(path)
#endif

View File

@@ -90,17 +90,17 @@ namespace Path
std::string GetFileName(std::string_view path)
{
return fs::u8path(path).filename().string();
return u8path(path).filename().string();
}
std::string GetFileNameWithoutExtension(std::string_view path)
{
return fs::u8path(path).stem().string();
return u8path(path).stem().string();
}
std::string GetExtension(std::string_view path)
{
return fs::u8path(path).extension().string();
return u8path(path).extension().string();
}
utf8* GetAbsolute(utf8* buffer, size_t bufferSize, const utf8* relativePath)

View File

@@ -769,7 +769,7 @@ static std::string ResolveFilenameForCapture(const fs::path& filename)
return *path;
}
auto screenshotDirectory = fs::u8path(screenshot_get_directory());
auto screenshotDirectory = u8path(screenshot_get_directory());
auto screenshotPath = fs::absolute(screenshotDirectory / filename);
// Check the filename isn't attempting to leave the screenshot directory for security

View File

@@ -16,6 +16,7 @@
# include "../core/String.hpp"
# include "Platform2.h"
# include <cerrno>
# include <clocale>
# include <cstdlib>
# include <cstring>

View File

@@ -99,7 +99,7 @@ bool platform_ensure_directory_exists(const utf8* path)
bool platform_directory_delete(const utf8* path)
{
return fs::remove_all(fs::u8path(path)) > 0;
return fs::remove_all(u8path(path)) > 0;
}
std::string platform_get_absolute_path(const utf8* relative_path, const utf8* base_path)

View File

@@ -115,7 +115,7 @@ namespace Platform
bool FileExists(std::string_view path)
{
fs::path file = fs::u8path(path);
fs::path file = u8path(path);
log_verbose("Checking if file exists: %s", std::string(path).c_str());
return fs::exists(file);
}

View File

@@ -176,7 +176,7 @@ private:
{
if (String::Equals(Path::GetExtension(path), ".sea", true))
{
auto data = DecryptSea(fs::u8path(path));
auto data = DecryptSea(u8path(path));
auto ms = std::make_unique<MemoryStream>();
// Need to copy the data into MemoryStream as the overload will borrow instead of copy.
ms->Write(data.data(), data.size());

View File

@@ -64,7 +64,7 @@ namespace OpenRCT2::Scripting
try
{
CaptureOptions captureOptions;
captureOptions.Filename = fs::u8path(AsOrDefault(options["filename"], ""));
captureOptions.Filename = u8path(AsOrDefault(options["filename"], ""));
captureOptions.Rotation = options["rotation"].as_int() & 3;
captureOptions.Zoom = ZoomLevel(options["zoom"].as_int());
captureOptions.Transparent = AsOrDefault(options["transparent"], false);