diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2024-03-16 14:46:08 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2024-03-20 20:38:04 -0500 |
| commit | f922129255b996bff481decf681f66bfabb0a086 (patch) | |
| tree | b884ea290b46aa5d35e8a152363806989b0c7a42 /Source/Core | |
| parent | 369502b49b9573875e6bab053a60b36ed8e30440 (diff) | |
Core/State: Display messages on state write failures.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/State.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index d60747deeb..83c7655203 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -402,7 +402,7 @@ static void CompressAndDumpState(CompressAndDumpState_args& save_args) File::IOFile f(temp_filename, "wb"); if (!f) { - Core::DisplayMessage("Could not save state", 2000); + Core::DisplayMessage("Failed to create state file", 2000); return; } @@ -413,6 +413,9 @@ static void CompressAndDumpState(CompressAndDumpState_args& save_args) else f.WriteBytes(buffer_data, buffer_size); + if (!f.IsGood()) + Core::DisplayMessage("Failed to write state file", 2000); + const std::string last_state_filename = File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav"; const std::string last_state_dtmname = last_state_filename + ".dtm"; const std::string dtmname = filename + ".dtm"; @@ -448,12 +451,20 @@ static void CompressAndDumpState(CompressAndDumpState_args& save_args) // Move written state to final location. // TODO: This should also be atomic. This is possible on all systems, but needs a special // implementation of IOFile on Windows. - f.Close(); - File::Rename(temp_filename, filename); + if (!f.Close()) + Core::DisplayMessage("Failed to close state file", 2000); + + if (!File::Rename(temp_filename, filename)) + { + Core::DisplayMessage("Failed to rename state file", 2000); + } + else + { + const std::filesystem::path temp_path(filename); + Core::DisplayMessage(fmt::format("Saved State to {}", temp_path.filename().string()), 2000); + } } - std::filesystem::path tempfilename(filename); - Core::DisplayMessage(fmt::format("Saved State to {}", tempfilename.filename().string()), 2000); Host_UpdateMainFrame(); } |
