From c9dc8676a6328b59989abb5253d9039fcd4fc449 Mon Sep 17 00:00:00 2001 From: Stan Date: Sun, 14 Aug 2022 17:55:08 +0000 Subject: [PATCH] Fix mod installation in non latin folders. Use OSString for consistency. Refs e7ab22286e Refs 880a797ce0 Refs 404e1a9a4a Refs 52baaa4bbd This was SVN commit r27055. --- source/ps/Mod.cpp | 7 ++++++- source/ps/ModInstaller.cpp | 18 ++++++++++++++++-- source/ps/ModInstaller.h | 3 ++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/ps/Mod.cpp b/source/ps/Mod.cpp index f1486d7c09..efd5387bf9 100644 --- a/source/ps/Mod.cpp +++ b/source/ps/Mod.cpp @@ -33,6 +33,11 @@ #include "scriptinterface/ScriptExceptions.h" #include "scriptinterface/ScriptInterface.h" +#if !OS_WIN +#include "lib/os_path.h" +#include "lib/path.h" +#endif + #include #include #include @@ -55,7 +60,7 @@ bool LoadModJSON(const PIVFS& vfs, OsPath modsPath, OsPath mod, std::string& tex #if OS_WIN const std::filesystem::path modJsonPath = (modsPath / mod / L"mod.json").fileSystemPath(); #else - const std::string modJsonPath = (modsPath / mod / L"mod.json").string8(); + const Path::String modJsonPath = OsString(modsPath / mod / L"mod.json").c_str(); #endif // Attempt to open mod.json first. std::ifstream modjson(modJsonPath); diff --git a/source/ps/ModInstaller.cpp b/source/ps/ModInstaller.cpp index a0b51624b5..20d1e69baa 100644 --- a/source/ps/ModInstaller.cpp +++ b/source/ps/ModInstaller.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -21,13 +21,22 @@ #include "lib/file/vfs/vfs_util.h" #include "lib/file/file_system.h" +#include "lib/sysdep/os.h" #include "ps/CLogger.h" #include "ps/Filesystem.h" #include "ps/XML/Xeromyces.h" #include "scriptinterface/ScriptInterface.h" #include "scriptinterface/JSON.h" +#if !OS_WIN +#include "lib/os_path.h" +#include "lib/path.h" +#endif + #include +#if OS_WIN +#include +#endif CModInstaller::CModInstaller(const OsPath& modsdir, const OsPath& tempdir) : m_ModsDir(modsdir), m_TempDir(tempdir / "_modscache"), m_CacheDir("cache/") @@ -107,7 +116,12 @@ CModInstaller::ModInstallationResult CModInstaller::Install( DeleteDirectory(modTemp.Parent()); - std::ofstream mod_json((modDir / "mod.json").string8()); +#if OS_WIN + const std::filesystem::path modJsonPath = (modDir / L"mod.json").fileSystemPath(); +#else + const Path::String modJsonPath = OsString(modDir / L"mod.json").c_str(); +#endif + std::ofstream mod_json(modJsonPath); if (mod_json.good()) { mod_json << modinfo.GetAsString(); diff --git a/source/ps/ModInstaller.h b/source/ps/ModInstaller.h index a5c3143393..1f8236ca32 100644 --- a/source/ps/ModInstaller.h +++ b/source/ps/ModInstaller.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "CStr.h" #include "lib/file/vfs/vfs.h" +#include #include class ScriptContext;