aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/romfs.cpp
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-12-03 16:26:14 -0500
committerGitHub <noreply@github.com>2023-12-03 16:26:14 -0500
commitfedeff7a8936f2528860611a42206ecd5d306248 (patch)
tree0d5d6c620ebd87b3d8524229d9f3fe5958fa2025 /src/core/file_sys/romfs.cpp
parent69529a748c7ca5c92d13c3a29fa8c3eb6148ae56 (diff)
parent45b6161582e0dd5b54fd3c06b3176f5b32ca10aa (diff)
Merge pull request #12263 from liamwhite/null-romfs
file_sys: handle null romfs
Diffstat (limited to 'src/core/file_sys/romfs.cpp')
-rw-r--r--src/core/file_sys/romfs.cpp19
1 files changed, 13 insertions, 6 deletions
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;
}