diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index 885a141822..5eec5382ce 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -162,8 +162,6 @@ std::string& GetExeDirectory(); bool WriteStringToFile(const std::string& str, const std::string& filename); bool ReadFileToString(const std::string& filename, std::string& str); -} // namespace - // To deal with Windows being dumb at unicode: template void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) @@ -174,3 +172,5 @@ void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmod fstream.open(filename.c_str(), openmode); #endif } + +} // namespace diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index 1543d0f96f..5c38dd6a19 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -401,7 +401,7 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data) // Open file std::ifstream in; - OpenFStream(in, filename, std::ios::in); + File::OpenFStream(in, filename, std::ios::in); if (in.fail()) return false; @@ -474,7 +474,7 @@ bool IniFile::Save(const std::string& filename) { std::ofstream out; std::string temp = File::GetTempFilenameForAtomicWrite(filename); - OpenFStream(out, temp, std::ios::out); + File::OpenFStream(out, temp, std::ios::out); if (out.fail()) { diff --git a/Source/Core/Common/LinearDiskCache.h b/Source/Core/Common/LinearDiskCache.h index 2db1a0ad82..630a624d6b 100644 --- a/Source/Core/Common/LinearDiskCache.h +++ b/Source/Core/Common/LinearDiskCache.h @@ -70,7 +70,7 @@ public: m_num_entries = 0; // try opening for reading/writing - OpenFStream(m_file, filename, ios_base::in | ios_base::out | ios_base::binary); + File::OpenFStream(m_file, filename, ios_base::in | ios_base::out | ios_base::binary); m_file.seekg(0, std::ios::end); std::fstream::pos_type end_pos = m_file.tellg(); diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 3b2d925047..2c09bc5051 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -170,7 +170,7 @@ LogContainer::LogContainer(const std::string& shortName, const std::string& full FileLogListener::FileLogListener(const std::string& filename) { - OpenFStream(m_logfile, filename, std::ios::app); + File::OpenFStream(m_logfile, filename, std::ios::app); SetEnable(true); } diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 0e45f869b4..76d27f3714 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -268,8 +268,8 @@ void Wiimote::WriteData(const wm_write_data* const wd) { // TODO Only write parts of the Mii block std::ofstream file; - OpenFStream(file, File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin", - std::ios::binary | std::ios::out); + File::OpenFStream(file, File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin", + std::ios::binary | std::ios::out); file.write((char*)m_eeprom + 0x0FCA, 0x02f0); file.close(); } diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index adb2872e21..fb66bfb093 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -144,7 +144,7 @@ void Wiimote::SpeakerData(const wm_speaker_data* sd) File::Delete("rmtdump.wav"); File::Delete("rmtdump.bin"); atexit(stopdamnwav); - OpenFStream(ofile, "rmtdump.bin", ofile.binary | ofile.out); + File::OpenFStream(ofile, "rmtdump.bin", ofile.binary | ofile.out); wav.Start("rmtdump.wav", 6000); } wav.AddMonoSamples(samples.get(), sd->length * 2); diff --git a/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp index 66572169f7..ee03ddeeb4 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp @@ -18,7 +18,7 @@ bool CSVSignatureDB::Load(const std::string& file_path) { std::string line; std::ifstream ifs; - OpenFStream(ifs, file_path, std::ios_base::in); + File::OpenFStream(ifs, file_path, std::ios_base::in); if (!ifs) return false; diff --git a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp index 9e1a924667..80617f0ab3 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp @@ -128,7 +128,7 @@ void MEGASignatureDB::Clear() bool MEGASignatureDB::Load(const std::string& file_path) { std::ifstream ifs; - OpenFStream(ifs, file_path, std::ios_base::in); + File::OpenFStream(ifs, file_path, std::ios_base::in); if (!ifs) return false; diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp index 286aba930e..fee6e13f68 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -53,7 +53,7 @@ static bool LoadMap(const std::string& file_path, Map& map, std::function predicate) { std::ifstream txt; - OpenFStream(txt, file_path, std::ios::in); + File::OpenFStream(txt, file_path, std::ios::in); if (!txt.is_open()) return false; diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index 2a536c95e6..77ecf38f55 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -321,7 +321,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) if (!path.IsEmpty()) { std::ifstream f; - OpenFStream(f, WxStrToStr(path), std::ios_base::in); + File::OpenFStream(f, WxStrToStr(path), std::ios_base::in); std::string line; while (std::getline(f, line)) diff --git a/Source/Core/VideoBackends/D3D/D3DShader.cpp b/Source/Core/VideoBackends/D3D/D3DShader.cpp index c1bdeb0d3c..cd9622b4a3 100644 --- a/Source/Core/VideoBackends/D3D/D3DShader.cpp +++ b/Source/Core/VideoBackends/D3D/D3DShader.cpp @@ -54,7 +54,7 @@ bool CompileVertexShader(const std::string& code, D3DBlob** blob) std::string filename = StringFromFormat("%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << code; file.close(); @@ -112,7 +112,7 @@ bool CompileGeometryShader(const std::string& code, D3DBlob** blob, std::string filename = StringFromFormat("%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << code; file.close(); @@ -169,7 +169,7 @@ bool CompilePixelShader(const std::string& code, D3DBlob** blob, const D3D_SHADE std::string filename = StringFromFormat("%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << code; file.close(); diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index d0474dc3b7..44027314b7 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -310,7 +310,7 @@ bool ProgramShaderCache::CompileShader(SHADER& shader, const std::string& vcode, std::string filename = StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << vcode << s_glsl_header << pcode; if (!gcode.empty()) file << s_glsl_header << gcode; @@ -381,7 +381,7 @@ bool ProgramShaderCache::CompileComputeShader(SHADER& shader, const std::string& std::string filename = StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << code; file << info_log; file.close(); @@ -448,7 +448,7 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const std::string& c std::string filename = StringFromFormat( "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), prefix, num_failures++); std::ofstream file; - OpenFStream(file, filename, std::ios_base::out); + File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << code << info_log; file.close(); diff --git a/Source/Core/VideoBackends/OGL/VertexManager.cpp b/Source/Core/VideoBackends/OGL/VertexManager.cpp index 58d7b19ad9..eb7ce04c92 100644 --- a/Source/Core/VideoBackends/OGL/VertexManager.cpp +++ b/Source/Core/VideoBackends/OGL/VertexManager.cpp @@ -179,13 +179,13 @@ void VertexManager::vFlush() std::string filename = StringFromFormat( "%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId); std::ofstream fps; - OpenFStream(fps, filename, std::ios_base::out); + File::OpenFStream(fps, filename, std::ios_base::out); fps << prog.shader.strpprog; filename = StringFromFormat("%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId); std::ofstream fvs; - OpenFStream(fvs, filename, std::ios_base::out); + File::OpenFStream(fvs, filename, std::ios_base::out); fvs << prog.shader.strvprog; } #endif diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp index d4d095bb78..75bf99a3ba 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp @@ -131,7 +131,7 @@ bool CompileShaderToSPV(SPIRVCodeVector* out_code, EShLanguage stage, const char "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), stage_filename, counter++); std::ofstream stream; - OpenFStream(stream, filename, std::ios_base::out); + File::OpenFStream(stream, filename, std::ios_base::out); if (stream.good()) { stream << full_source_code << std::endl; @@ -199,7 +199,7 @@ bool CompileShaderToSPV(SPIRVCodeVector* out_code, EShLanguage stage, const char stage_filename, counter++); std::ofstream stream; - OpenFStream(stream, filename, std::ios_base::out); + File::OpenFStream(stream, filename, std::ios_base::out); if (stream.good()) { stream << full_source_code << std::endl; diff --git a/Source/Core/VideoCommon/ImageWrite.cpp b/Source/Core/VideoCommon/ImageWrite.cpp index f944a37fb8..585ba5e13b 100644 --- a/Source/Core/VideoCommon/ImageWrite.cpp +++ b/Source/Core/VideoCommon/ImageWrite.cpp @@ -16,7 +16,7 @@ bool SaveData(const std::string& filename, const std::string& data) { std::ofstream f; - OpenFStream(f, filename, std::ios::binary); + File::OpenFStream(f, filename, std::ios::binary); f << data; return true;