From 285640dbdf807ad19281978fb00740c2ff447cf7 Mon Sep 17 00:00:00 2001 From: The Dax Date: Wed, 4 Jun 2014 22:41:42 -0400 Subject: [PATCH] CWCheats: Make sure to convert paths properly so that non-English paths are supported. --- Core/CwCheat.cpp | 7 +++++++ UI/CwCheatScreen.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 4610dd2c3d..c617600054 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -8,6 +8,9 @@ #include "Core/MIPS/MIPS.h" #include "Core/ELF/ParamSFO.h" #include "Core/System.h" +#ifdef _WIN32 +#include "util/text/utf8.h" +#endif static int CheatEvent = -1; std::string gameTitle; @@ -233,7 +236,11 @@ inline void trim2(std::string& str) { std::vector CWCheatEngine::GetCodesList() { //Reads the entire cheat list from the appropriate .ini. std::string line; std::vector codesList; // Read from INI here +#ifdef _WIN32 + std::ifstream list(ConvertUTF8ToWString(activeCheatFile)); +#else std::ifstream list(activeCheatFile.c_str()); +#endif if (!list) { return codesList; } diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index c751d99a68..3949657d1c 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -19,6 +19,9 @@ #include "input/input_state.h" #include "ui/ui.h" #include "i18n/i18n.h" +#ifdef _WIN32 +#include "util/text/utf8.h" +#endif #include "Core/Core.h" #include "Core/Config.h" @@ -145,7 +148,12 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) { std::vector newList; std::string cheatDir = GetSysDirectory(DIRECTORY_CHEATS) + "cheat.db"; + +#ifdef _WIN32 + is.open(ConvertUTF8ToWString(cheatDir)); +#else is.open(cheatDir.c_str()); +#endif while (is.good()) { getline(is, line); // get line from file @@ -186,10 +194,18 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) { } is.close(); std::string title2; +#ifdef _WIN32 + is.open(ConvertUTF8ToWString(activeCheatFile)); +#else is.open(activeCheatFile.c_str()); +#endif getline(is, title2); is.close(); +#ifdef _WIN32 + os.open(ConvertUTF8ToWString(activeCheatFile), std::ios::app); +#else os.open(activeCheatFile.c_str(), std::ios::app); +#endif auto it = title.begin(); if (title2.substr(0, 2) != "_S" && it != title.end() && (++it) != title.end()) { os << title[0] << "\n" << title[1]; @@ -221,7 +237,11 @@ void CwCheatScreen::processFileOn(std::string activatedCheat) { } } +#ifdef _WIN32 + os.open(ConvertUTF8ToWString(activeCheatFile)); +#else os.open(activeCheatFile.c_str()); +#endif for (size_t j = 0; j < cheatList.size(); j++) { os << cheatList[j]; if (j < cheatList.size() - 1) { @@ -238,7 +258,11 @@ void CwCheatScreen::processFileOff(std::string deactivatedCheat) { } } +#ifdef _WIN32 + os.open(ConvertUTF8ToWString(activeCheatFile)); +#else os.open(activeCheatFile.c_str()); +#endif for (size_t j = 0; j < cheatList.size(); j++) { os << cheatList[j]; if (j < cheatList.size() - 1) {