From 54de8739f1a2d75020241f6c1ad435cd83795882 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sun, 13 Oct 2013 19:30:07 -0400 Subject: [PATCH] Fix critical bug with GetSysDirectories. --- Common/FileUtil.cpp | 8 ++++---- Common/FileUtil.h | 2 +- Core/System.cpp | 4 ++-- UI/NativeApp.cpp | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index cba169bd8d..179e9222c6 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -652,13 +652,13 @@ std::string GetBundleDirectory() #endif #ifdef _WIN32 -std::string &GetExeDirectory() +std::wstring &GetExeDirectory() { - static std::string DolphinPath; + static std::wstring DolphinPath; if (DolphinPath.empty()) { - char Dolphin_exe_Path[2048]; - GetModuleFileNameA(NULL, Dolphin_exe_Path, 2048); + wchar_t Dolphin_exe_Path[2048]; + GetModuleFileName(NULL, Dolphin_exe_Path, 2048); DolphinPath = Dolphin_exe_Path; DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); } diff --git a/Common/FileUtil.h b/Common/FileUtil.h index a3306588fc..25dca98009 100644 --- a/Common/FileUtil.h +++ b/Common/FileUtil.h @@ -125,7 +125,7 @@ std::string GetBundleDirectory(); #endif #ifdef _WIN32 -std::string &GetExeDirectory(); +std::wstring &GetExeDirectory(); #endif // simple wrapper for cstdlib file functions to diff --git a/Core/System.cpp b/Core/System.cpp index b71c887047..31ffc1ce1c 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -363,7 +363,7 @@ CoreParameter &PSP_CoreParameter() { void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { #ifdef _WIN32 - std::string path = File::GetExeDirectory(); + std::string path = ConvertWStringToUTF8(File::GetExeDirectory()); // Mount a filesystem flash0path = path + "/flash0/"; @@ -402,7 +402,7 @@ void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { // We're screwed anyway if we can't write to Documents, or can't detect it. std::string testFile = "/_writable_test.$$$"; - if (!File::CreateEmptyFile(path + testFile)) + if (!File::CreateEmptyFile(memstickpath + testFile)) memstickpath = ConvertWStringToUTF8(myDocumentsPath) + "/PPSSPP/"; // Clean up our mess. diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 87e6c9c169..6cd559f04f 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -36,6 +36,7 @@ #include "file/zip_read.h" #include "native/ext/stb_image_write/stb_image_writer.h" #include "native/ext/jpge/jpge.h" +#include "native/util/text/utf8.h" #include "gfx_es2/gl_state.h" #include "gfx_es2/draw_text.h" #include "gfx/gl_lost_manager.h" @@ -368,7 +369,7 @@ void NativeInit(int argc, const char *argv[], INFO_LOG(BOOT, "Logger inited."); #else if (g_Config.currentDirectory.empty()) { - g_Config.currentDirectory = File::GetExeDirectory(); + g_Config.currentDirectory = ConvertWStringToUTF8(File::GetExeDirectory()); } g_Config.memCardDirectory = "MemStick/"; #endif