From 9d8a82e1d9d945d68b17adab1aff34c96aeda003 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 5 Dec 2017 21:23:35 +0100 Subject: [PATCH] Don't use wrong encoding for paths when opening streams on Windows --- Source/Core/Common/ArmCPUDetect.cpp | 4 +++- Source/Core/Common/LinearDiskCache.h | 2 +- Source/Core/Core/DSP/DSPDisassembler.cpp | 1 - Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp | 4 ++-- Source/Core/Core/MemoryWatcher.cpp | 3 ++- Source/Core/DolphinWX/Frame.cpp | 3 ++- Source/Core/VideoCommon/FPSCounter.cpp | 5 ++++- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Source/Core/Common/ArmCPUDetect.cpp b/Source/Core/Common/ArmCPUDetect.cpp index 382983db6f..9c85835c07 100644 --- a/Source/Core/Common/ArmCPUDetect.cpp +++ b/Source/Core/Common/ArmCPUDetect.cpp @@ -12,6 +12,7 @@ #include "Common/CPUDetect.h" #include "Common/CommonTypes.h" +#include "Common/FileUtil.h" #include "Common/StringUtil.h" const char procfile[] = "/proc/cpuinfo"; @@ -22,7 +23,8 @@ static std::string GetCPUString() std::string cpu_string = "Unknown"; std::string line; - std::ifstream file(procfile); + std::ifstream file; + File::OpenFStream(file, procfile, std::ios_base::in); if (!file) return cpu_string; diff --git a/Source/Core/Common/LinearDiskCache.h b/Source/Core/Common/LinearDiskCache.h index fae1dfc3f5..e97f23a11f 100644 --- a/Source/Core/Common/LinearDiskCache.h +++ b/Source/Core/Common/LinearDiskCache.h @@ -124,7 +124,7 @@ public: // failed to open file for reading or bad header // close and recreate file Close(); - m_file.open(filename, ios_base::out | ios_base::trunc | ios_base::binary); + File::OpenFStream(m_file, filename, ios_base::out | ios_base::trunc | ios_base::binary); WriteHeader(); return 0; } diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index af736cad2a..8b6c030fe0 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 76d27f3714..ae7f06283d 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -400,8 +400,8 @@ void Wiimote::ReadData(const wm_read_data* const rd) { // TODO Only read the Mii block parts required std::ifstream file; - file.open((File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin").c_str(), - std::ios::binary | std::ios::in); + File::OpenFStream(file, (File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin").c_str(), + std::ios::binary | std::ios::in); file.read((char*)m_eeprom + 0x0FCA, 0x02f0); file.close(); } diff --git a/Source/Core/Core/MemoryWatcher.cpp b/Source/Core/Core/MemoryWatcher.cpp index 3aea80a6b6..635a1ed9e7 100644 --- a/Source/Core/Core/MemoryWatcher.cpp +++ b/Source/Core/Core/MemoryWatcher.cpp @@ -58,7 +58,8 @@ MemoryWatcher::~MemoryWatcher() bool MemoryWatcher::LoadAddresses(const std::string& path) { - std::ifstream locations(path); + std::ifstream locations; + File::OpenFStream(locations, path, std::ios_base::in); if (!locations) return false; diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index d1f8693417..ccfdd729d2 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -150,7 +150,8 @@ void CRenderFrame::OnDropFiles(wxDropFilesEvent& event) bool CRenderFrame::IsValidSavestateDropped(const std::string& filepath) { const int game_id_length = 6; - std::ifstream file(filepath, std::ios::in | std::ios::binary); + std::ifstream file; + File::OpenFStream(file, filepath, std::ios::in | std::ios::binary); if (!file) return false; diff --git a/Source/Core/VideoCommon/FPSCounter.cpp b/Source/Core/VideoCommon/FPSCounter.cpp index 86b3ab5c85..24d49548df 100644 --- a/Source/Core/VideoCommon/FPSCounter.cpp +++ b/Source/Core/VideoCommon/FPSCounter.cpp @@ -21,7 +21,10 @@ FPSCounter::FPSCounter() void FPSCounter::LogRenderTimeToFile(u64 val) { if (!m_bench_file.is_open()) - m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt"); + { + File::OpenFStream(m_bench_file, File::GetUserPath(D_LOGS_IDX) + "render_time.txt", + std::ios_base::out); + } m_bench_file << std::fixed << std::setprecision(8) << (val / 1000.0) << std::endl; }