summaryrefslogtreecommitdiff
path: root/src/frontend_common/content_manager.h
diff options
context:
space:
mode:
authorGravatar t8952024-01-24 12:34:50 -0500
committerGravatar t8952024-01-25 12:53:49 -0500
commit97ca160b08537314ca6ba953a382aebda3da06b9 (patch)
tree53282078af75ecba5ad87c5bcd3ea1cdb14f0249 /src/frontend_common/content_manager.h
parentfrontend_common: Remove key rederivation and keep key check (diff)
downloadyuzu-97ca160b08537314ca6ba953a382aebda3da06b9.tar.gz
yuzu-97ca160b08537314ca6ba953a382aebda3da06b9.tar.xz
yuzu-97ca160b08537314ca6ba953a382aebda3da06b9.zip
frontend_common: Consistently use references
Was swapping between references and pointers for no reason. Just unify them here since each of these utility functions will need their parameters to be alive.
Diffstat (limited to 'src/frontend_common/content_manager.h')
-rw-r--r--src/frontend_common/content_manager.h56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h
index fb92a1695..1cbaa73f7 100644
--- a/src/frontend_common/content_manager.h
+++ b/src/frontend_common/content_manager.h
@@ -47,14 +47,14 @@ inline bool RemoveDLC(const Service::FileSystem::FileSystemController& fs_contro
47 47
48/** 48/**
49 * \brief Removes all DLC for a game 49 * \brief Removes all DLC for a game
50 * \param system Raw pointer to the system instance 50 * \param system Reference to the system instance
51 * \param program_id Program ID for the game that will have all of its DLC removed 51 * \param program_id Program ID for the game that will have all of its DLC removed
52 * \return Number of DLC removed 52 * \return Number of DLC removed
53 */ 53 */
54inline size_t RemoveAllDLC(Core::System* system, const u64 program_id) { 54inline size_t RemoveAllDLC(Core::System& system, const u64 program_id) {
55 size_t count{}; 55 size_t count{};
56 const auto& fs_controller = system->GetFileSystemController(); 56 const auto& fs_controller = system.GetFileSystemController();
57 const auto dlc_entries = system->GetContentProvider().ListEntriesFilter( 57 const auto dlc_entries = system.GetContentProvider().ListEntriesFilter(
58 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); 58 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
59 std::vector<u64> program_dlc_entries; 59 std::vector<u64> program_dlc_entries;
60 60
@@ -124,15 +124,15 @@ inline bool RemoveMod(const Service::FileSystem::FileSystemController& fs_contro
124 124
125/** 125/**
126 * \brief Installs an NSP 126 * \brief Installs an NSP
127 * \param system Raw pointer to the system instance 127 * \param system Reference to the system instance
128 * \param vfs Raw pointer to the VfsFilesystem instance in Core::System 128 * \param vfs Reference to the VfsFilesystem instance in Core::System
129 * \param filename Path to the NSP file 129 * \param filename Path to the NSP file
130 * \param callback Callback to report the progress of the installation. The first size_t 130 * \param callback Callback to report the progress of the installation. The first size_t
131 * parameter is the total size of the virtual file and the second is the current progress. If you 131 * parameter is the total size of the virtual file and the second is the current progress. If you
132 * return true to the callback, it will cancel the installation as soon as possible. 132 * return true to the callback, it will cancel the installation as soon as possible.
133 * \return [InstallResult] representing how the installation finished 133 * \return [InstallResult] representing how the installation finished
134 */ 134 */
135inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vfs, 135inline InstallResult InstallNSP(Core::System& system, FileSys::VfsFilesystem& vfs,
136 const std::string& filename, 136 const std::string& filename,
137 const std::function<bool(size_t, size_t)>& callback) { 137 const std::function<bool(size_t, size_t)>& callback) {
138 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, 138 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
@@ -159,7 +159,7 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf
159 }; 159 };
160 160
161 std::shared_ptr<FileSys::NSP> nsp; 161 std::shared_ptr<FileSys::NSP> nsp;
162 FileSys::VirtualFile file = vfs->OpenFile(filename, FileSys::Mode::Read); 162 FileSys::VirtualFile file = vfs.OpenFile(filename, FileSys::Mode::Read);
163 if (boost::to_lower_copy(file->GetName()).ends_with(std::string("nsp"))) { 163 if (boost::to_lower_copy(file->GetName()).ends_with(std::string("nsp"))) {
164 nsp = std::make_shared<FileSys::NSP>(file); 164 nsp = std::make_shared<FileSys::NSP>(file);
165 if (nsp->IsExtractedType()) { 165 if (nsp->IsExtractedType()) {
@@ -173,7 +173,7 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf
173 return InstallResult::Failure; 173 return InstallResult::Failure;
174 } 174 }
175 const auto res = 175 const auto res =
176 system->GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true, copy); 176 system.GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true, copy);
177 switch (res) { 177 switch (res) {
178 case FileSys::InstallResult::Success: 178 case FileSys::InstallResult::Success:
179 return InstallResult::Success; 179 return InstallResult::Success;
@@ -188,17 +188,17 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf
188 188
189/** 189/**
190 * \brief Installs an NCA 190 * \brief Installs an NCA
191 * \param vfs Raw pointer to the VfsFilesystem instance in Core::System 191 * \param vfs Reference to the VfsFilesystem instance in Core::System
192 * \param filename Path to the NCA file 192 * \param filename Path to the NCA file
193 * \param registered_cache Raw pointer to the registered cache that the NCA will be installed to 193 * \param registered_cache Reference to the registered cache that the NCA will be installed to
194 * \param title_type Type of NCA package to install 194 * \param title_type Type of NCA package to install
195 * \param callback Callback to report the progress of the installation. The first size_t 195 * \param callback Callback to report the progress of the installation. The first size_t
196 * parameter is the total size of the virtual file and the second is the current progress. If you 196 * parameter is the total size of the virtual file and the second is the current progress. If you
197 * return true to the callback, it will cancel the installation as soon as possible. 197 * return true to the callback, it will cancel the installation as soon as possible.
198 * \return [InstallResult] representing how the installation finished 198 * \return [InstallResult] representing how the installation finished
199 */ 199 */
200inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string& filename, 200inline InstallResult InstallNCA(FileSys::VfsFilesystem& vfs, const std::string& filename,
201 FileSys::RegisteredCache* registered_cache, 201 FileSys::RegisteredCache& registered_cache,
202 const FileSys::TitleType title_type, 202 const FileSys::TitleType title_type,
203 const std::function<bool(size_t, size_t)>& callback) { 203 const std::function<bool(size_t, size_t)>& callback) {
204 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, 204 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
@@ -224,7 +224,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string&
224 return true; 224 return true;
225 }; 225 };
226 226
227 const auto nca = std::make_shared<FileSys::NCA>(vfs->OpenFile(filename, FileSys::Mode::Read)); 227 const auto nca = std::make_shared<FileSys::NCA>(vfs.OpenFile(filename, FileSys::Mode::Read));
228 const auto id = nca->GetStatus(); 228 const auto id = nca->GetStatus();
229 229
230 // Game updates necessary are missing base RomFS 230 // Game updates necessary are missing base RomFS
@@ -233,7 +233,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string&
233 return InstallResult::Failure; 233 return InstallResult::Failure;
234 } 234 }
235 235
236 const auto res = registered_cache->InstallEntry(*nca, title_type, true, copy); 236 const auto res = registered_cache.InstallEntry(*nca, title_type, true, copy);
237 if (res == FileSys::InstallResult::Success) { 237 if (res == FileSys::InstallResult::Success) {
238 return InstallResult::Success; 238 return InstallResult::Success;
239 } else if (res == FileSys::InstallResult::OverwriteExisting) { 239 } else if (res == FileSys::InstallResult::OverwriteExisting) {
@@ -245,19 +245,19 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string&
245 245
246/** 246/**
247 * \brief Verifies the installed contents for a given ManualContentProvider 247 * \brief Verifies the installed contents for a given ManualContentProvider
248 * \param system Raw pointer to the system instance 248 * \param system Reference to the system instance
249 * \param provider Raw pointer to the content provider that's tracking indexed games 249 * \param provider Reference to the content provider that's tracking indexed games
250 * \param callback Callback to report the progress of the installation. The first size_t 250 * \param callback Callback to report the progress of the installation. The first size_t
251 * parameter is the total size of the installed contents and the second is the current progress. If 251 * parameter is the total size of the installed contents and the second is the current progress. If
252 * you return true to the callback, it will cancel the installation as soon as possible. 252 * you return true to the callback, it will cancel the installation as soon as possible.
253 * \return A list of entries that failed to install. Returns an empty vector if successful. 253 * \return A list of entries that failed to install. Returns an empty vector if successful.
254 */ 254 */
255inline std::vector<std::string> VerifyInstalledContents( 255inline std::vector<std::string> VerifyInstalledContents(
256 Core::System* system, FileSys::ManualContentProvider* provider, 256 Core::System& system, FileSys::ManualContentProvider& provider,
257 const std::function<bool(size_t, size_t)>& callback) { 257 const std::function<bool(size_t, size_t)>& callback) {
258 // Get content registries. 258 // Get content registries.
259 auto bis_contents = system->GetFileSystemController().GetSystemNANDContents(); 259 auto bis_contents = system.GetFileSystemController().GetSystemNANDContents();
260 auto user_contents = system->GetFileSystemController().GetUserNANDContents(); 260 auto user_contents = system.GetFileSystemController().GetUserNANDContents();
261 261
262 std::vector<FileSys::RegisteredCache*> content_providers; 262 std::vector<FileSys::RegisteredCache*> content_providers;
263 if (bis_contents) { 263 if (bis_contents) {
@@ -309,11 +309,11 @@ inline std::vector<std::string> VerifyInstalledContents(
309 const auto title_id = nca.GetTitleId(); 309 const auto title_id = nca.GetTitleId();
310 std::string title_name = "unknown"; 310 std::string title_name = "unknown";
311 311
312 const auto control = provider->GetEntry(FileSys::GetBaseTitleID(title_id), 312 const auto control = provider.GetEntry(FileSys::GetBaseTitleID(title_id),
313 FileSys::ContentRecordType::Control); 313 FileSys::ContentRecordType::Control);
314 if (control && control->GetStatus() == Loader::ResultStatus::Success) { 314 if (control && control->GetStatus() == Loader::ResultStatus::Success) {
315 const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), 315 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
316 *provider}; 316 provider};
317 const auto [nacp, logo] = pm.ParseControlNCA(*control); 317 const auto [nacp, logo] = pm.ParseControlNCA(*control);
318 if (nacp) { 318 if (nacp) {
319 title_name = nacp->GetApplicationName(); 319 title_name = nacp->GetApplicationName();
@@ -335,7 +335,7 @@ inline std::vector<std::string> VerifyInstalledContents(
335 335
336/** 336/**
337 * \brief Verifies the contents of a given game 337 * \brief Verifies the contents of a given game
338 * \param system Raw pointer to the system instance 338 * \param system Reference to the system instance
339 * \param game_path Patch to the game file 339 * \param game_path Patch to the game file
340 * \param callback Callback to report the progress of the installation. The first size_t 340 * \param callback Callback to report the progress of the installation. The first size_t
341 * parameter is the total size of the installed contents and the second is the current progress. If 341 * parameter is the total size of the installed contents and the second is the current progress. If
@@ -343,10 +343,10 @@ inline std::vector<std::string> VerifyInstalledContents(
343 * \return GameVerificationResult representing how the verification process finished 343 * \return GameVerificationResult representing how the verification process finished
344 */ 344 */
345inline GameVerificationResult VerifyGameContents( 345inline GameVerificationResult VerifyGameContents(
346 Core::System* system, const std::string& game_path, 346 Core::System& system, const std::string& game_path,
347 const std::function<bool(size_t, size_t)>& callback) { 347 const std::function<bool(size_t, size_t)>& callback) {
348 const auto loader = Loader::GetLoader( 348 const auto loader =
349 *system, system->GetFilesystem()->OpenFile(game_path, FileSys::Mode::Read)); 349 Loader::GetLoader(system, system.GetFilesystem()->OpenFile(game_path, FileSys::Mode::Read));
350 if (loader == nullptr) { 350 if (loader == nullptr) {
351 return GameVerificationResult::NotImplemented; 351 return GameVerificationResult::NotImplemented;
352 } 352 }