From 447d2b6f9330876b06e2d02031f028ce37dc7fbf Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 23 Feb 2021 06:35:35 +0200 Subject: [PATCH] Atomic RSX capture writes --- rpcs3/Emu/RSX/RSXThread.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 5d8b3bf3fa..9628812499 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -2889,10 +2889,13 @@ namespace rsx capture_current_frame = false; const std::string file_path = fs::get_config_dir() + "captures/" + Emu.GetTitleID() + "_" + date_time::current_time_narrow() + "_capture.rrc"; - const std::string file_data = cereal_serialize(frame_capture); // todo: may want to compress this data? - if (fs::write_file(file_path, fs::rewrite, file_data)) + const std::string file_data = cereal_serialize(frame_capture); + + fs::pending_file temp(file_path); + + if (temp.file && (temp.file.write(file_data), temp.commit(false))) { rsx_log.success("Capture successful: %s", file_path); }