summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Liam2023-12-01 23:39:48 -0500
committerGravatar Liam2023-12-01 23:39:48 -0500
commit45b6161582e0dd5b54fd3c06b3176f5b32ca10aa (patch)
treeeeef2fc18a459377ab40e9fb36810b08fd31c11b /src/core/file_sys
parentMerge pull request #12255 from german77/amiibo (diff)
downloadyuzu-45b6161582e0dd5b54fd3c06b3176f5b32ca10aa.tar.gz
yuzu-45b6161582e0dd5b54fd3c06b3176f5b32ca10aa.tar.xz
yuzu-45b6161582e0dd5b54fd3c06b3176f5b32ca10aa.zip
file_sys: handle null romfs
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/patch_manager.cpp4
-rw-r--r--src/core/file_sys/romfs.cpp19
-rw-r--r--src/core/file_sys/romfs_factory.cpp2
3 files changed, 14 insertions, 11 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 0bca05587..cc7af2ea3 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -429,10 +429,6 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs
429 LOG_DEBUG(Loader, "{}", log_string); 429 LOG_DEBUG(Loader, "{}", log_string);
430 } 430 }
431 431
432 if (base_romfs == nullptr) {
433 return base_romfs;
434 }
435
436 auto romfs = base_romfs; 432 auto romfs = base_romfs;
437 433
438 // Game Updates 434 // Game Updates
diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp
index 1eb1f439a..6de2103a0 100644
--- a/src/core/file_sys/romfs.cpp
+++ b/src/core/file_sys/romfs.cpp
@@ -3,6 +3,7 @@
3 3
4#include <memory> 4#include <memory>
5 5
6#include "common/assert.h"
6#include "common/common_types.h" 7#include "common/common_types.h"
7#include "common/string_util.h" 8#include "common/string_util.h"
8#include "common/swap.h" 9#include "common/swap.h"
@@ -101,24 +102,30 @@ void ProcessDirectory(const VirtualFile& file, std::size_t dir_offset, std::size
101} // Anonymous namespace 102} // Anonymous namespace
102 103
103VirtualDir ExtractRomFS(VirtualFile file) { 104VirtualDir ExtractRomFS(VirtualFile file) {
105 auto root_container = std::make_shared<VectorVfsDirectory>();
106 if (!file) {
107 return root_container;
108 }
109
104 RomFSHeader header{}; 110 RomFSHeader header{};
105 if (file->ReadObject(&header) != sizeof(RomFSHeader)) 111 if (file->ReadObject(&header) != sizeof(RomFSHeader)) {
106 return nullptr; 112 return root_container;
113 }
107 114
108 if (header.header_size != sizeof(RomFSHeader)) 115 if (header.header_size != sizeof(RomFSHeader)) {
109 return nullptr; 116 return root_container;
117 }
110 118
111 const u64 file_offset = header.file_meta.offset; 119 const u64 file_offset = header.file_meta.offset;
112 const u64 dir_offset = header.directory_meta.offset; 120 const u64 dir_offset = header.directory_meta.offset;
113 121
114 auto root_container = std::make_shared<VectorVfsDirectory>();
115
116 ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container); 122 ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container);
117 123
118 if (auto root = root_container->GetSubdirectory(""); root) { 124 if (auto root = root_container->GetSubdirectory(""); root) {
119 return std::make_shared<CachedVfsDirectory>(std::move(root)); 125 return std::make_shared<CachedVfsDirectory>(std::move(root));
120 } 126 }
121 127
128 ASSERT(false);
122 return nullptr; 129 return nullptr;
123} 130}
124 131
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 1bc07dae5..35e149905 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -22,7 +22,7 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader, ContentProvider& provi
22 : content_provider{provider}, filesystem_controller{controller} { 22 : content_provider{provider}, filesystem_controller{controller} {
23 // Load the RomFS from the app 23 // Load the RomFS from the app
24 if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { 24 if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) {
25 LOG_ERROR(Service_FS, "Unable to read RomFS!"); 25 LOG_WARNING(Service_FS, "Unable to read base RomFS");
26 } 26 }
27 27
28 updatable = app_loader.IsRomFSUpdatable(); 28 updatable = app_loader.IsRomFSUpdatable();