mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2025-10-30 08:02:29 +00:00
Fixed Windows filesystem error crash
From Zelda64Recomp/Zelda64Recomp#271 commit 1ea7d4ebe9dcf522faa13cab513f88c3217ba011
This commit is contained in:
parent
eb666c9e01
commit
e41c7cce6d
2 changed files with 20 additions and 13 deletions
|
|
@ -110,21 +110,28 @@ std::filesystem::path get_save_file_path_backup() {
|
|||
}
|
||||
|
||||
void update_save_file() {
|
||||
{
|
||||
std::ofstream save_file{ get_save_file_path_temp(), std::ios_base::binary };
|
||||
|
||||
if (save_file.good()) {
|
||||
std::lock_guard lock{ save_context.save_buffer_mutex };
|
||||
save_file.write(save_context.save_buffer.data(), save_context.save_buffer.size());
|
||||
|
||||
if (std::filesystem::exists(get_save_file_path())) {
|
||||
std::filesystem::rename(get_save_file_path(), get_save_file_path_backup());
|
||||
} else {
|
||||
printf("\nSavefile doesn't exist. Skip renaming.\n");
|
||||
}
|
||||
std::filesystem::rename(get_save_file_path_temp(), get_save_file_path());
|
||||
} else {
|
||||
else {
|
||||
ultramodern::error_handling::message_box("Failed to write to the save file. Check your file permissions. If you have moved your appdata folder to Dropbox or similar, this can cause issues.");
|
||||
}
|
||||
}
|
||||
|
||||
std::error_code ec;
|
||||
if (std::filesystem::exists(get_save_file_path(), ec)) {
|
||||
std::filesystem::copy_file(get_save_file_path(), get_save_file_path_backup(), std::filesystem::copy_options::overwrite_existing, ec);
|
||||
if (ec) {
|
||||
printf("[ERROR] Failed to copy save file backup\n");
|
||||
}
|
||||
}
|
||||
std::filesystem::copy_file(get_save_file_path_temp(), get_save_file_path(), std::filesystem::copy_options::overwrite_existing, ec);
|
||||
if (ec) {
|
||||
ultramodern::error_handling::message_box("Failed to write to the save file. Check your file permissions. If you have moved your appdata folder to Dropbox or similar, this can cause issues.");
|
||||
// std::exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
2
rt64
2
rt64
|
|
@ -1 +1 @@
|
|||
Subproject commit 64b9e166f75b4dc44a59983b67c3e9ecc1f4cfd7
|
||||
Subproject commit 1adcbea31a04f2403da729eb5dfed3950dd7ec52
|
||||
Loading…
Add table
Reference in a new issue