diff options
| author | 2018-09-19 22:04:51 -0400 | |
|---|---|---|
| committer | 2018-09-21 19:53:33 -0400 | |
| commit | 050547b801ccc7cfea65c142658e8d2a987472d2 (patch) | |
| tree | 079655ab43528f76d14d06ad747d2c2251ef81f7 /src/core/file_sys/romfs.cpp | |
| parent | file_sys: Port Atmosphere-NX fs_mitm implementation (diff) | |
| download | yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.gz yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.tar.xz yuzu-050547b801ccc7cfea65c142658e8d2a987472d2.zip | |
romfs: Implement CreateRomFS
Diffstat (limited to 'src/core/file_sys/romfs.cpp')
| -rw-r--r-- | src/core/file_sys/romfs.cpp | 20 |
1 files changed, 17 insertions, 3 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 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/swap.h" | 6 | #include "common/swap.h" |
| 7 | #include "core/file_sys/fsmitm_romfsbuild.hpp" | ||
| 7 | #include "core/file_sys/romfs.h" | 8 | #include "core/file_sys/romfs.h" |
| 8 | #include "core/file_sys/vfs.h" | 9 | #include "core/file_sys/vfs.h" |
| 10 | #include "core/file_sys/vfs_concat.h" | ||
| 9 | #include "core/file_sys/vfs_offset.h" | 11 | #include "core/file_sys/vfs_offset.h" |
| 10 | #include "core/file_sys/vfs_vector.h" | 12 | #include "core/file_sys/vfs_vector.h" |
| 11 | 13 | ||
| @@ -98,7 +100,7 @@ void ProcessDirectory(VirtualFile file, std::size_t dir_offset, std::size_t file | |||
| 98 | } | 100 | } |
| 99 | } | 101 | } |
| 100 | 102 | ||
| 101 | VirtualDir ExtractRomFS(VirtualFile file) { | 103 | VirtualDir ExtractRomFS(VirtualFile file, bool traverse_into_data) { |
| 102 | RomFSHeader header{}; | 104 | RomFSHeader header{}; |
| 103 | if (file->ReadObject(&header) != sizeof(RomFSHeader)) | 105 | if (file->ReadObject(&header) != sizeof(RomFSHeader)) |
| 104 | return nullptr; | 106 | return nullptr; |
| @@ -117,9 +119,21 @@ VirtualDir ExtractRomFS(VirtualFile file) { | |||
| 117 | 119 | ||
| 118 | VirtualDir out = std::move(root); | 120 | VirtualDir out = std::move(root); |
| 119 | 121 | ||
| 120 | while (out->GetSubdirectory("") != nullptr) | 122 | while (out->GetSubdirectories().size() == 1 && out->GetFiles().size() == 0) { |
| 121 | out = out->GetSubdirectory(""); | 123 | if (out->GetSubdirectories().front()->GetName() == "data" && !traverse_into_data) |
| 124 | break; | ||
| 125 | out = out->GetSubdirectories().front(); | ||
| 126 | } | ||
| 122 | 127 | ||
| 123 | return out; | 128 | return out; |
| 124 | } | 129 | } |
| 130 | |||
| 131 | VirtualFile CreateRomFS(VirtualDir dir) { | ||
| 132 | if (dir == nullptr) | ||
| 133 | return nullptr; | ||
| 134 | |||
| 135 | RomFSBuildContext ctx{dir}; | ||
| 136 | return ConcatenateFiles<0>(ctx.Build(), dir->GetName()); | ||
| 137 | } | ||
| 138 | |||
| 125 | } // namespace FileSys | 139 | } // namespace FileSys |