summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-12-03 22:26:14 +0100
committerGitHub <noreply@github.com>2023-12-03 22:26:14 +0100
commitfedeff7a8936f2528860611a42206ecd5d306248 (patch)
tree0d5d6c620ebd87b3d8524229d9f3fe5958fa2025
parentMerge pull request #12261 from liamwhite/fruit-company (diff)
parentfile_sys: handle null romfs (diff)
downloadyuzu-fedeff7a8936f2528860611a42206ecd5d306248.tar
yuzu-fedeff7a8936f2528860611a42206ecd5d306248.tar.gz
yuzu-fedeff7a8936f2528860611a42206ecd5d306248.tar.bz2
yuzu-fedeff7a8936f2528860611a42206ecd5d306248.tar.lz
yuzu-fedeff7a8936f2528860611a42206ecd5d306248.tar.xz
yuzu-fedeff7a8936f2528860611a42206ecd5d306248.tar.zst
yuzu-fedeff7a8936f2528860611a42206ecd5d306248.zip
-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
-rw-r--r--src/core/loader/nca.cpp6
-rw-r--r--src/yuzu/main.cpp5
5 files changed, 16 insertions, 20 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
LOG_DEBUG(Loader, "{}", log_string);
}
- if (base_romfs == nullptr) {
- return base_romfs;
- }
-
auto romfs = base_romfs;
// 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 @@
#include <memory>
+#include "common/assert.h"
#include "common/common_types.h"
#include "common/string_util.h"
#include "common/swap.h"
@@ -101,24 +102,30 @@ void ProcessDirectory(const VirtualFile& file, std::size_t dir_offset, std::size
} // Anonymous namespace
VirtualDir ExtractRomFS(VirtualFile file) {
+ auto root_container = std::make_shared<VectorVfsDirectory>();
+ if (!file) {
+ return root_container;
+ }
+
RomFSHeader header{};
- if (file->ReadObject(&header) != sizeof(RomFSHeader))
- return nullptr;
+ if (file->ReadObject(&header) != sizeof(RomFSHeader)) {
+ return root_container;
+ }
- if (header.header_size != sizeof(RomFSHeader))
- return nullptr;
+ if (header.header_size != sizeof(RomFSHeader)) {
+ return root_container;
+ }
const u64 file_offset = header.file_meta.offset;
const u64 dir_offset = header.directory_meta.offset;
- auto root_container = std::make_shared<VectorVfsDirectory>();
-
ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container);
if (auto root = root_container->GetSubdirectory(""); root) {
return std::make_shared<CachedVfsDirectory>(std::move(root));
}
+ ASSERT(false);
return nullptr;
}
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
: content_provider{provider}, filesystem_controller{controller} {
// Load the RomFS from the app
if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) {
- LOG_ERROR(Service_FS, "Unable to read RomFS!");
+ LOG_WARNING(Service_FS, "Unable to read base RomFS");
}
updatable = app_loader.IsRomFSUpdatable();
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp
index 4feb6968a..814407535 100644
--- a/src/core/loader/nca.cpp
+++ b/src/core/loader/nca.cpp
@@ -74,10 +74,8 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S
return load_result;
}
- if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) {
- system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>(
- *this, system.GetContentProvider(), system.GetFileSystemController()));
- }
+ system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>(
+ *this, system.GetContentProvider(), system.GetFileSystemController()));
is_loaded = true;
return load_result;
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 10c788290..b056c3717 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -2713,11 +2713,6 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
}
const auto base_romfs = base_nca->GetRomFS();
- if (!base_romfs) {
- failed();
- return;
- }
-
const auto dump_dir =
target == DumpRomFSTarget::Normal
? Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir)