diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-09-20 04:04:51 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-09-22 01:53:33 +0200 |
commit | 050547b801ccc7cfea65c142658e8d2a987472d2 (patch) | |
tree | 079655ab43528f76d14d06ad747d2c2251ef81f7 /src/core/file_sys | |
parent | file_sys: Port Atmosphere-NX fs_mitm implementation (diff) | |
download | yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.gz yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.bz2 yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.lz yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.xz yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.zst yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.zip |
Diffstat (limited to 'src/core/file_sys')
-rw-r--r-- | src/core/file_sys/romfs.cpp | 20 | ||||
-rw-r--r-- | src/core/file_sys/romfs.h | 9 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 9f6e41cdf..71e4e0e2f 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -4,8 +4,10 @@ #include "common/common_types.h" #include "common/swap.h" +#include "core/file_sys/fsmitm_romfsbuild.hpp" #include "core/file_sys/romfs.h" #include "core/file_sys/vfs.h" +#include "core/file_sys/vfs_concat.h" #include "core/file_sys/vfs_offset.h" #include "core/file_sys/vfs_vector.h" @@ -98,7 +100,7 @@ void ProcessDirectory(VirtualFile file, std::size_t dir_offset, std::size_t file } } -VirtualDir ExtractRomFS(VirtualFile file) { +VirtualDir ExtractRomFS(VirtualFile file, bool traverse_into_data) { RomFSHeader header{}; if (file->ReadObject(&header) != sizeof(RomFSHeader)) return nullptr; @@ -117,9 +119,21 @@ VirtualDir ExtractRomFS(VirtualFile file) { VirtualDir out = std::move(root); - while (out->GetSubdirectory("") != nullptr) - out = out->GetSubdirectory(""); + while (out->GetSubdirectories().size() == 1 && out->GetFiles().size() == 0) { + if (out->GetSubdirectories().front()->GetName() == "data" && !traverse_into_data) + break; + out = out->GetSubdirectories().front(); + } return out; } + +VirtualFile CreateRomFS(VirtualDir dir) { + if (dir == nullptr) + return nullptr; + + RomFSBuildContext ctx{dir}; + return ConcatenateFiles<0>(ctx.Build(), dir->GetName()); +} + } // namespace FileSys diff --git a/src/core/file_sys/romfs.h b/src/core/file_sys/romfs.h index e54a7d7a9..8e82585a0 100644 --- a/src/core/file_sys/romfs.h +++ b/src/core/file_sys/romfs.h @@ -5,6 +5,7 @@ #pragma once #include <array> +#include <map> #include "common/common_funcs.h" #include "common/common_types.h" #include "common/swap.h" @@ -12,6 +13,8 @@ namespace FileSys { +struct RomFSHeader; + struct IVFCLevel { u64_le offset; u64_le size; @@ -31,6 +34,10 @@ static_assert(sizeof(IVFCHeader) == 0xE0, "IVFCHeader has incorrect size."); // Converts a RomFS binary blob to VFS Filesystem // Returns nullptr on failure -VirtualDir ExtractRomFS(VirtualFile file); +VirtualDir ExtractRomFS(VirtualFile file, bool traverse_into_data = true); + +// Converts a VFS filesystem into a RomFS binary +// Returns nullptr on failure +VirtualFile CreateRomFS(VirtualDir dir); } // namespace FileSys |