Fix auto updating ncch files
This commit is contained in:
parent
67c4b87184
commit
c49379442d
|
@ -738,6 +738,10 @@ void SetCurrentRomPath(const std::string& path) {
|
||||||
g_currentRomPath = path;
|
g_currentRomPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& GetCurrentRomPath() {
|
||||||
|
return g_currentRomPath;
|
||||||
|
}
|
||||||
|
|
||||||
bool StringReplace(std::string& haystack, const std::string& a, const std::string& b, bool swap) {
|
bool StringReplace(std::string& haystack, const std::string& a, const std::string& b, bool swap) {
|
||||||
const auto& needle = swap ? b : a;
|
const auto& needle = swap ? b : a;
|
||||||
const auto& replacement = swap ? a : b;
|
const auto& replacement = swap ? a : b;
|
||||||
|
|
|
@ -182,6 +182,8 @@ void SetUserPath(const std::string& path = "");
|
||||||
|
|
||||||
void SetCurrentRomPath(const std::string& path);
|
void SetCurrentRomPath(const std::string& path);
|
||||||
|
|
||||||
|
const std::string& GetCurrentRomPath();
|
||||||
|
|
||||||
// Returns a pointer to a string with a Citra data dir in the user's home
|
// Returns a pointer to a string with a Citra data dir in the user's home
|
||||||
// directory. To be used in "multi-user" mode (that is, installed).
|
// directory. To be used in "multi-user" mode (that is, installed).
|
||||||
[[nodiscard]] const std::string& GetUserPath(UserPath path);
|
[[nodiscard]] const std::string& GetUserPath(UserPath path);
|
||||||
|
|
|
@ -324,6 +324,7 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
|
||||||
status = ResultStatus::Success;
|
status = ResultStatus::Success;
|
||||||
m_emu_window = &emu_window;
|
m_emu_window = &emu_window;
|
||||||
m_filepath = filepath;
|
m_filepath = filepath;
|
||||||
|
self_delete_pending = false;
|
||||||
|
|
||||||
// Reset counters and set time origin to current frame
|
// Reset counters and set time origin to current frame
|
||||||
[[maybe_unused]] const PerfStats::Results result = GetAndResetPerfStats();
|
[[maybe_unused]] const PerfStats::Results result = GetAndResetPerfStats();
|
||||||
|
@ -556,6 +557,10 @@ void System::Shutdown(bool is_deserializing) {
|
||||||
|
|
||||||
memory.reset();
|
memory.reset();
|
||||||
|
|
||||||
|
if (self_delete_pending)
|
||||||
|
FileUtil::Delete(m_filepath);
|
||||||
|
self_delete_pending = false;
|
||||||
|
|
||||||
LOG_DEBUG(Core, "Shutdown OK");
|
LOG_DEBUG(Core, "Shutdown OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,6 +305,12 @@ public:
|
||||||
|
|
||||||
void LoadState(u32 slot);
|
void LoadState(u32 slot);
|
||||||
|
|
||||||
|
/// Self delete ncch
|
||||||
|
void SetSelfDelete(const std::string& file) {
|
||||||
|
if (m_filepath == file)
|
||||||
|
self_delete_pending = true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Initialize the emulated system.
|
* Initialize the emulated system.
|
||||||
|
@ -374,6 +380,7 @@ private:
|
||||||
Frontend::EmuWindow* m_emu_window;
|
Frontend::EmuWindow* m_emu_window;
|
||||||
std::string m_filepath;
|
std::string m_filepath;
|
||||||
u64 title_id;
|
u64 title_id;
|
||||||
|
bool self_delete_pending;
|
||||||
|
|
||||||
std::mutex signal_mutex;
|
std::mutex signal_mutex;
|
||||||
Signal current_signal;
|
Signal current_signal;
|
||||||
|
|
|
@ -318,7 +318,12 @@ bool CIAFile::Close() const {
|
||||||
if (abort)
|
if (abort)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
FileUtil::Delete(GetTitleContentPath(media_type, old_tmd.GetTitleID(), old_index));
|
// Try deleting the file, if it fails it's because it's the currently running file
|
||||||
|
// and we are on windows. In that case, let system know to delete the currently
|
||||||
|
// running file once it shuts down.
|
||||||
|
std::string toDelete = GetTitleContentPath(media_type, old_tmd.GetTitleID(), old_index);
|
||||||
|
if (!FileUtil::Delete(toDelete) && FileUtil::GetCurrentRomPath() == toDelete)
|
||||||
|
Core::System::GetInstance().SetSelfDelete(toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtil::Delete(old_tmd_path);
|
FileUtil::Delete(old_tmd_path);
|
||||||
|
|
Reference in New Issue