mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Fix auto updating ncch files
This commit is contained in:
		
							parent
							
								
									67c4b87184
								
							
						
					
					
						commit
						c49379442d
					
				
					 5 changed files with 24 additions and 1 deletions
				
			
		|  | @ -738,6 +738,10 @@ void SetCurrentRomPath(const std::string& 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) { | ||||
|     const auto& needle = swap ? b : a; | ||||
|     const auto& replacement = swap ? a : b; | ||||
|  |  | |||
|  | @ -182,6 +182,8 @@ void SetUserPath(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
 | ||||
| // directory. To be used in "multi-user" mode (that is, installed).
 | ||||
| [[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; | ||||
|     m_emu_window = &emu_window; | ||||
|     m_filepath = filepath; | ||||
|     self_delete_pending = false; | ||||
| 
 | ||||
|     // Reset counters and set time origin to current frame
 | ||||
|     [[maybe_unused]] const PerfStats::Results result = GetAndResetPerfStats(); | ||||
|  | @ -556,6 +557,10 @@ void System::Shutdown(bool is_deserializing) { | |||
| 
 | ||||
|     memory.reset(); | ||||
| 
 | ||||
|     if (self_delete_pending) | ||||
|         FileUtil::Delete(m_filepath); | ||||
|     self_delete_pending = false; | ||||
| 
 | ||||
|     LOG_DEBUG(Core, "Shutdown OK"); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -305,6 +305,12 @@ public: | |||
| 
 | ||||
|     void LoadState(u32 slot); | ||||
| 
 | ||||
|     /// Self delete ncch
 | ||||
|     void SetSelfDelete(const std::string& file) { | ||||
|         if (m_filepath == file) | ||||
|             self_delete_pending = true; | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|     /**
 | ||||
|      * Initialize the emulated system. | ||||
|  | @ -374,6 +380,7 @@ private: | |||
|     Frontend::EmuWindow* m_emu_window; | ||||
|     std::string m_filepath; | ||||
|     u64 title_id; | ||||
|     bool self_delete_pending; | ||||
| 
 | ||||
|     std::mutex signal_mutex; | ||||
|     Signal current_signal; | ||||
|  |  | |||
|  | @ -318,7 +318,12 @@ bool CIAFile::Close() const { | |||
|             if (abort) | ||||
|                 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); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue