diff options
Diffstat (limited to 'src/core/file_sys/romfs.cpp')
-rw-r--r-- | src/core/file_sys/romfs.cpp | 19 |
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; } |