From 008806c27556d114f1973f55b970794fac12e224 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Wed, 28 Jan 2015 06:15:05 +0800 Subject: [PATCH] Fix as @hrydgard suggest --- Core/CwCheat.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 612e13587c..722af616af 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -1,3 +1,5 @@ +#include "i18n/i18n.h" +#include "UI/OnScreenDisplay.h" #include "Common/StringUtils.h" #include "Common/ChunkFile.h" #include "Common/FileUtil.h" @@ -13,7 +15,7 @@ #include "util/text/utf8.h" #endif -using namespace std; + static int CheatEvent = -1; std::string gameTitle; @@ -41,10 +43,15 @@ static void __CheatStart() { File::CreateFullPath(GetSysDirectory(DIRECTORY_CHEATS)); if (!File::Exists(activeCheatFile)) { - ofstream myCheatFile; - myCheatFile.open(activeCheatFile.c_str()); - myCheatFile << "\xEF\xBB\xBF"; - myCheatFile.close(); + FILE *f = File::OpenCFile(activeCheatFile, "wb"); + if (f) { + fwrite("\xEF\xBB\xBF", 1, 3, f); + fclose(f); + } + if (!File::Exists(activeCheatFile)) { + I18NCategory *err = GetI18NCategory("Error"); + osm.Show(err->T("Unable to create cheat file, disk may be full")); + } }