mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 17:02:40 +00:00
copy saves to backup folder every 5 mins
This commit is contained in:
parent
122fe22a32
commit
5a67a10883
@ -1,8 +1,11 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <set>
|
||||
#include <fmt/core.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "common/config.h"
|
||||
#include "common/debug.h"
|
||||
@ -330,6 +333,11 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file, std::string
|
||||
linker->LoadModule(entry.path());
|
||||
}
|
||||
}
|
||||
|
||||
if (!game_serial.empty()) {
|
||||
std::thread savethread(StartAutosave, game_serial);
|
||||
savethread.detach();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_QT_GUI
|
||||
@ -402,4 +410,23 @@ void Emulator::UpdatePlayTime(const std::string& serial) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void StartAutosave(std::string game_serial) {
|
||||
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::minutes(5));
|
||||
const auto backup_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir) /
|
||||
"savedata" / "1" / game_serial / "BACKUPSAVES";
|
||||
const auto save_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "savedata" /
|
||||
"1" / game_serial / "SPRJ0005";
|
||||
try {
|
||||
std::filesystem::copy(save_dir, backup_dir,
|
||||
std::filesystem::copy_options::overwrite_existing |
|
||||
std::filesystem::copy_options::recursive);
|
||||
LOG_INFO(Config, "Backup saves created");
|
||||
} catch (std::exception& ex) {
|
||||
fmt::print("Error creating backup saves. Exception: {}\n", ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
void StartAutosave(std::string game_serial);
|
||||
|
||||
using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
|
||||
|
||||
struct SysModules {
|
||||
@ -30,7 +32,6 @@ public:
|
||||
|
||||
private:
|
||||
void LoadSystemModules(const std::filesystem::path& file, std::string game_serial);
|
||||
|
||||
Core::MemoryManager* memory;
|
||||
Input::GameController* controller;
|
||||
Core::Linker* linker;
|
||||
|
Loading…
Reference in New Issue
Block a user