diff --git a/Core/ELF/PBPReader.cpp b/Core/ELF/PBPReader.cpp index de9c4452bd..5749cf85a6 100644 --- a/Core/ELF/PBPReader.cpp +++ b/Core/ELF/PBPReader.cpp @@ -15,7 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include #include #include diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4607c75efd..5d3471cb40 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -15,7 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include #include #include diff --git a/Core/System.cpp b/Core/System.cpp index 60a2e03b6b..93539bad07 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -644,24 +644,21 @@ void InitSysDirectories() { // If installed.txt exists(and we can determine the Documents directory) if (installed && rootMyDocsPath.size() > 0) { -#if defined(_WIN32) && defined(__MINGW32__) - std::ifstream inputFile(installedFile); -#else - std::ifstream inputFile(ConvertUTF8ToWString(installedFile)); -#endif - - if (!inputFile.fail() && inputFile.is_open()) { - std::string tempString; - - std::getline(inputFile, tempString); - + FILE *fp = File::OpenCFile(installedFile, "rt"); + if (fp) { + char temp[2048]; + char *tempStr = fgets(temp, sizeof(temp), fp); // Skip UTF-8 encoding bytes if there are any. There are 3 of them. - if (tempString.substr(0, 3) == "\xEF\xBB\xBF") - tempString = tempString.substr(3); + if (tempStr && strncmp(tempStr, "\xEF\xBB\xBF", 3) == 0) { + tempStr += 3; + } + std::string tempString = tempStr ? tempStr : ""; + if (!tempString.empty() && tempString.back() == '\n') + tempString.resize(tempString.size() - 1); g_Config.memStickDirectory = tempString; + fclose(fp); } - inputFile.close(); // Check if the file is empty first, before appending the slash. if (g_Config.memStickDirectory.empty()) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3fceddf23d..8c7fc3da12 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -958,25 +958,21 @@ void GameSettingsScreen::CreateViews() { SavePathInMyDocumentChoice->SetEnabled(false); } else { if (installed_ && myDocsExists) { -#ifdef _MSC_VER - std::ifstream inputFile(ConvertUTF8ToWString(installedFile)); -#else - std::ifstream inputFile(installedFile); -#endif - if (!inputFile.fail() && inputFile.is_open()) { - std::string tempString; - std::getline(inputFile, tempString); - + FILE *testInstalled = File::OpenCFile(installedFile, "rt"); + if (testInstalled) { + char temp[2048]; + char *tempStr = fgets(temp, sizeof(temp), testInstalled); // Skip UTF-8 encoding bytes if there are any. There are 3 of them. - if (tempString.substr(0, 3) == "\xEF\xBB\xBF") - tempString = tempString.substr(3); + if (tempStr && strncmp(tempStr, "\xEF\xBB\xBF", 3) == 0) { + tempStr += 3; + } SavePathInOtherChoice->SetEnabled(!PSP_IsInited()); - if (!(tempString == "")) { + if (tempStr && strlen(tempStr) != 0 && strcmp(tempStr, "\n") != 0) { installed_ = false; otherinstalled_ = true; } + fclose(testInstalled); } - inputFile.close(); } else if (!myDocsExists) { SavePathInMyDocumentChoice->SetEnabled(false); } diff --git a/Windows/stdafx.h b/Windows/stdafx.h index e8c667e29a..97093c82b5 100644 --- a/Windows/stdafx.h +++ b/Windows/stdafx.h @@ -67,6 +67,5 @@ #include #include #include -#include #include "Common/Log.h"