Add a namespace to OpenFStream

For consistency with the other functions in FileUtil.h.
This commit is contained in:
JosJuice 2017-01-15 22:46:43 +01:00
parent f09ceaa735
commit cf94ce6305
15 changed files with 24 additions and 24 deletions

View File

@ -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)
@ -174,3 +172,5 @@ void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmod
fstream.open(filename.c_str(), openmode);
#endif
}
} // namespace

View File

@ -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())
{

View File

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

View File

@ -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);
}

View File

@ -268,7 +268,7 @@ 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",
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();

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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))

View File

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

View File

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

View File

@ -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

View File

@ -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;

View File

@ -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;