Add a namespace to OpenFStream
For consistency with the other functions in FileUtil.h.
This commit is contained in:
parent
f09ceaa735
commit
cf94ce6305
|
@ -162,8 +162,6 @@ std::string& GetExeDirectory();
|
||||||
bool WriteStringToFile(const std::string& str, const std::string& filename);
|
bool WriteStringToFile(const std::string& str, const std::string& filename);
|
||||||
bool ReadFileToString(const std::string& filename, std::string& str);
|
bool ReadFileToString(const std::string& filename, std::string& str);
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// To deal with Windows being dumb at unicode:
|
// To deal with Windows being dumb at unicode:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
|
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);
|
fstream.open(filename.c_str(), openmode);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
|
@ -401,7 +401,7 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
OpenFStream(in, filename, std::ios::in);
|
File::OpenFStream(in, filename, std::ios::in);
|
||||||
|
|
||||||
if (in.fail())
|
if (in.fail())
|
||||||
return false;
|
return false;
|
||||||
|
@ -474,7 +474,7 @@ bool IniFile::Save(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
std::string temp = File::GetTempFilenameForAtomicWrite(filename);
|
std::string temp = File::GetTempFilenameForAtomicWrite(filename);
|
||||||
OpenFStream(out, temp, std::ios::out);
|
File::OpenFStream(out, temp, std::ios::out);
|
||||||
|
|
||||||
if (out.fail())
|
if (out.fail())
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
m_num_entries = 0;
|
m_num_entries = 0;
|
||||||
|
|
||||||
// try opening for reading/writing
|
// 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);
|
m_file.seekg(0, std::ios::end);
|
||||||
std::fstream::pos_type end_pos = m_file.tellg();
|
std::fstream::pos_type end_pos = m_file.tellg();
|
||||||
|
|
|
@ -170,7 +170,7 @@ LogContainer::LogContainer(const std::string& shortName, const std::string& full
|
||||||
|
|
||||||
FileLogListener::FileLogListener(const std::string& filename)
|
FileLogListener::FileLogListener(const std::string& filename)
|
||||||
{
|
{
|
||||||
OpenFStream(m_logfile, filename, std::ios::app);
|
File::OpenFStream(m_logfile, filename, std::ios::app);
|
||||||
SetEnable(true);
|
SetEnable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,8 +268,8 @@ void Wiimote::WriteData(const wm_write_data* const wd)
|
||||||
{
|
{
|
||||||
// TODO Only write parts of the Mii block
|
// TODO Only write parts of the Mii block
|
||||||
std::ofstream file;
|
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);
|
std::ios::binary | std::ios::out);
|
||||||
file.write((char*)m_eeprom + 0x0FCA, 0x02f0);
|
file.write((char*)m_eeprom + 0x0FCA, 0x02f0);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ void Wiimote::SpeakerData(const wm_speaker_data* sd)
|
||||||
File::Delete("rmtdump.wav");
|
File::Delete("rmtdump.wav");
|
||||||
File::Delete("rmtdump.bin");
|
File::Delete("rmtdump.bin");
|
||||||
atexit(stopdamnwav);
|
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.Start("rmtdump.wav", 6000);
|
||||||
}
|
}
|
||||||
wav.AddMonoSamples(samples.get(), sd->length * 2);
|
wav.AddMonoSamples(samples.get(), sd->length * 2);
|
||||||
|
|
|
@ -18,7 +18,7 @@ bool CSVSignatureDB::Load(const std::string& file_path)
|
||||||
{
|
{
|
||||||
std::string line;
|
std::string line;
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
OpenFStream(ifs, file_path, std::ios_base::in);
|
File::OpenFStream(ifs, file_path, std::ios_base::in);
|
||||||
|
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -128,7 +128,7 @@ void MEGASignatureDB::Clear()
|
||||||
bool MEGASignatureDB::Load(const std::string& file_path)
|
bool MEGASignatureDB::Load(const std::string& file_path)
|
||||||
{
|
{
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
OpenFStream(ifs, file_path, std::ios_base::in);
|
File::OpenFStream(ifs, file_path, std::ios_base::in);
|
||||||
|
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -53,7 +53,7 @@ static bool LoadMap(const std::string& file_path, Map& map,
|
||||||
std::function<bool(const std::string& game_id)> predicate)
|
std::function<bool(const std::string& game_id)> predicate)
|
||||||
{
|
{
|
||||||
std::ifstream txt;
|
std::ifstream txt;
|
||||||
OpenFStream(txt, file_path, std::ios::in);
|
File::OpenFStream(txt, file_path, std::ios::in);
|
||||||
|
|
||||||
if (!txt.is_open())
|
if (!txt.is_open())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -321,7 +321,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
||||||
if (!path.IsEmpty())
|
if (!path.IsEmpty())
|
||||||
{
|
{
|
||||||
std::ifstream f;
|
std::ifstream f;
|
||||||
OpenFStream(f, WxStrToStr(path), std::ios_base::in);
|
File::OpenFStream(f, WxStrToStr(path), std::ios_base::in);
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(f, line))
|
while (std::getline(f, line))
|
||||||
|
|
|
@ -54,7 +54,7 @@ bool CompileVertexShader(const std::string& code, D3DBlob** blob)
|
||||||
std::string filename = StringFromFormat("%sbad_vs_%04i.txt",
|
std::string filename = StringFromFormat("%sbad_vs_%04i.txt",
|
||||||
File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
OpenFStream(file, filename, std::ios_base::out);
|
File::OpenFStream(file, filename, std::ios_base::out);
|
||||||
file << code;
|
file << code;
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ bool CompileGeometryShader(const std::string& code, D3DBlob** blob,
|
||||||
std::string filename = StringFromFormat("%sbad_gs_%04i.txt",
|
std::string filename = StringFromFormat("%sbad_gs_%04i.txt",
|
||||||
File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
OpenFStream(file, filename, std::ios_base::out);
|
File::OpenFStream(file, filename, std::ios_base::out);
|
||||||
file << code;
|
file << code;
|
||||||
file.close();
|
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",
|
std::string filename = StringFromFormat("%sbad_ps_%04i.txt",
|
||||||
File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
OpenFStream(file, filename, std::ios_base::out);
|
File::OpenFStream(file, filename, std::ios_base::out);
|
||||||
file << code;
|
file << code;
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ bool ProgramShaderCache::CompileShader(SHADER& shader, const std::string& vcode,
|
||||||
std::string filename =
|
std::string filename =
|
||||||
StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
||||||
std::ofstream file;
|
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;
|
file << s_glsl_header << vcode << s_glsl_header << pcode;
|
||||||
if (!gcode.empty())
|
if (!gcode.empty())
|
||||||
file << s_glsl_header << gcode;
|
file << s_glsl_header << gcode;
|
||||||
|
@ -381,7 +381,7 @@ bool ProgramShaderCache::CompileComputeShader(SHADER& shader, const std::string&
|
||||||
std::string filename =
|
std::string filename =
|
||||||
StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
OpenFStream(file, filename, std::ios_base::out);
|
File::OpenFStream(file, filename, std::ios_base::out);
|
||||||
file << s_glsl_header << code;
|
file << s_glsl_header << code;
|
||||||
file << info_log;
|
file << info_log;
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -448,7 +448,7 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const std::string& c
|
||||||
std::string filename = StringFromFormat(
|
std::string filename = StringFromFormat(
|
||||||
"%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), prefix, num_failures++);
|
"%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), prefix, num_failures++);
|
||||||
std::ofstream file;
|
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 << s_glsl_header << code << info_log;
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
|
|
@ -179,13 +179,13 @@ void VertexManager::vFlush()
|
||||||
std::string filename = StringFromFormat(
|
std::string filename = StringFromFormat(
|
||||||
"%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
|
"%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
|
||||||
std::ofstream fps;
|
std::ofstream fps;
|
||||||
OpenFStream(fps, filename, std::ios_base::out);
|
File::OpenFStream(fps, filename, std::ios_base::out);
|
||||||
fps << prog.shader.strpprog;
|
fps << prog.shader.strpprog;
|
||||||
|
|
||||||
filename = StringFromFormat("%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
filename = StringFromFormat("%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
|
||||||
g_ActiveConfig.iSaveTargetId);
|
g_ActiveConfig.iSaveTargetId);
|
||||||
std::ofstream fvs;
|
std::ofstream fvs;
|
||||||
OpenFStream(fvs, filename, std::ios_base::out);
|
File::OpenFStream(fvs, filename, std::ios_base::out);
|
||||||
fvs << prog.shader.strvprog;
|
fvs << prog.shader.strvprog;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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++);
|
"%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), stage_filename, counter++);
|
||||||
|
|
||||||
std::ofstream stream;
|
std::ofstream stream;
|
||||||
OpenFStream(stream, filename, std::ios_base::out);
|
File::OpenFStream(stream, filename, std::ios_base::out);
|
||||||
if (stream.good())
|
if (stream.good())
|
||||||
{
|
{
|
||||||
stream << full_source_code << std::endl;
|
stream << full_source_code << std::endl;
|
||||||
|
@ -199,7 +199,7 @@ bool CompileShaderToSPV(SPIRVCodeVector* out_code, EShLanguage stage, const char
|
||||||
stage_filename, counter++);
|
stage_filename, counter++);
|
||||||
|
|
||||||
std::ofstream stream;
|
std::ofstream stream;
|
||||||
OpenFStream(stream, filename, std::ios_base::out);
|
File::OpenFStream(stream, filename, std::ios_base::out);
|
||||||
if (stream.good())
|
if (stream.good())
|
||||||
{
|
{
|
||||||
stream << full_source_code << std::endl;
|
stream << full_source_code << std::endl;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
bool SaveData(const std::string& filename, const std::string& data)
|
bool SaveData(const std::string& filename, const std::string& data)
|
||||||
{
|
{
|
||||||
std::ofstream f;
|
std::ofstream f;
|
||||||
OpenFStream(f, filename, std::ios::binary);
|
File::OpenFStream(f, filename, std::ios::binary);
|
||||||
f << data;
|
f << data;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue