Skip to content

Commit

Permalink
Add Unix timestamp to renamed corrupted file to prevent trying to cop…
Browse files Browse the repository at this point in the history
…y over existing file. (#3984)
  • Loading branch information
Malkierian committed Feb 29, 2024
1 parent ed9cb1d commit 368a901
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions soh/soh/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,6 @@ void SaveManager::SaveGlobal() {
output << std::setw(4) << globalBlock << std::endl;
}


void SaveManager::LoadFile(int fileNum) {
SPDLOG_INFO("Load File - fileNum: {}", fileNum);
std::filesystem::path fileName = GetFileName(fileNum);
Expand Down Expand Up @@ -1077,7 +1076,7 @@ void SaveManager::LoadFile(int fileNum) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnLoadFile>(fileNum);
} catch (const std::exception& e) {
input.close();
std::filesystem::path newFile(LUS::Context::GetPathRelativeToAppDirectory("Save") + ("/file" + std::to_string(fileNum + 1) + ".bak"));
std::filesystem::path newFile(LUS::Context::GetPathRelativeToAppDirectory("Save") + ("/file" + std::to_string(fileNum + 1) + "-" + std::to_string(GetUnixTimestamp()) + ".bak"));
#if defined(__SWITCH__) || defined(__WIIU__)
copy_file(fileName.c_str(), newFile.c_str());
#else
Expand Down

0 comments on commit 368a901

Please sign in to comment.