Skip to content

Commit

Permalink
Add a namespace to OpenFStream
Browse files Browse the repository at this point in the history
For consistency with the other functions in FileUtil.h.
  • Loading branch information
JosJuice committed Jun 15, 2017
1 parent f09ceaa commit cf94ce6
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Common/FileUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
Expand All @@ -174,3 +172,5 @@ void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmod
fstream.open(filename.c_str(), openmode);
#endif
}

} // namespace
4 changes: 2 additions & 2 deletions Source/Core/Common/IniFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/LinearDiskCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LinearDiskCache
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();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Logging/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/SignatureDB/CSVSignatureDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/TitleDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static bool LoadMap(const std::string& file_path, Map& map,
std::function<bool(const std::string& game_id)> 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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/D3D/D3DShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/OGL/VertexManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/ImageWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cf94ce6

Please sign in to comment.