1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Minor fs::file usage fixes

Do not crash on file creation failure. Make some config writes atomic.
This commit is contained in:
Elad Ashkenazi 2024-06-10 11:49:00 +03:00
parent 4c9296c07f
commit 0b22423ab8
9 changed files with 21 additions and 9 deletions

View File

@ -5292,7 +5292,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
if (g_cfg.core.llvm_logs)
{
out << *_module; // print IR
fs::file(cache_path + obj_name + ".log", fs::rewrite).write(out.str());
fs::write_file(cache_path + obj_name + ".log", fs::rewrite, out.str());
result.clear();
}

View File

@ -925,7 +925,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
log += "\n\n\n";
// Append log file
fs::file(m_spurt->get_cache_path() + "spu-ir.log", fs::write + fs::append).write(log);
fs::write_file(m_spurt->get_cache_path() + "spu-ir.log", fs::write + fs::append, log);
}
return fn;

View File

@ -1274,7 +1274,7 @@ spu_runtime::spu_runtime()
return;
}
if (g_cfg.core.spu_debug)
if (g_cfg.core.spu_debug && g_cfg.core.spu_decoder != spu_decoder_type::dynamic && g_cfg.core.spu_decoder != spu_decoder_type::_static)
{
if (!fs::create_dir(m_cache_path + "llvm/"))
{

View File

@ -2635,7 +2635,7 @@ public:
if (g_cfg.core.spu_debug)
{
fs::file(m_spurt->get_cache_path() + "spu-ir.log", fs::write + fs::append).write(log);
fs::write_file(m_spurt->get_cache_path() + "spu-ir.log", fs::write + fs::append, log);
}
if (auto& cache = g_fxo->get<spu_cache>())

View File

@ -29,7 +29,13 @@ bool mouse_config::load()
void mouse_config::save() const
{
fs::file(cfg_name, fs::rewrite).write(to_string());
fs::pending_file file(cfg_name);
if (file.file)
{
file.file.write(to_string());
file.commit();
}
}
cfg::string& mouse_config::get_button(int code)

View File

@ -130,7 +130,7 @@ namespace gl
break;
}
fs::file(fs::get_cache_dir() + base_name + std::to_string(m_id) + ".glsl", fs::rewrite).write(str, length);
fs::write_file(fs::get_cache_dir() + base_name + std::to_string(m_id) + ".glsl", fs::rewrite, str, length);
}
glShaderSource(m_id, 1, &str, &length);

View File

@ -426,7 +426,7 @@ void VKFragmentProgram::Decompile(const RSXFragmentProgram& prog)
void VKFragmentProgram::Compile()
{
if (g_cfg.video.log_programs)
fs::file(fs::get_cache_dir() + "shaderlog/FragmentProgram" + std::to_string(id) + ".spirv", fs::rewrite).write(shader.get_source());
fs::write_file(fs::get_cache_dir() + "shaderlog/FragmentProgram" + std::to_string(id) + ".spirv", fs::rewrite, shader.get_source());
handle = shader.compile();
}

View File

@ -361,7 +361,7 @@ void VKVertexProgram::Decompile(const RSXVertexProgram& prog)
void VKVertexProgram::Compile()
{
if (g_cfg.video.log_programs)
fs::file(fs::get_cache_dir() + "shaderlog/VertexProgram" + std::to_string(id) + ".spirv", fs::rewrite).write(shader.get_source());
fs::write_file(fs::get_cache_dir() + "shaderlog/VertexProgram" + std::to_string(id) + ".spirv", fs::rewrite, shader.get_source());
handle = shader.compile();
}

View File

@ -70,7 +70,13 @@ struct positive_axis : cfg::node
void save()
{
fs::file(cfg_name, fs::rewrite).write(to_string());
fs::pending_file file(cfg_name);
if (file.file)
{
file.file.write(to_string());
file.commit();
}
}
bool exist()