diff options
| author | 2018-09-25 16:59:44 -0400 | |
|---|---|---|
| committer | 2018-09-25 16:59:44 -0400 | |
| commit | 7b81e1e52565ee867c285e2b0c2526f8d4b82581 (patch) | |
| tree | 718decad5aae4153d8acaa444058914a1c12f147 /src/core/file_sys/romfs.cpp | |
| parent | Merge pull request #1393 from tech4me/svc (diff) | |
| parent | fsmitm: Cleanup and modernize fsmitm port (diff) | |
| download | yuzu-7b81e1e52565ee867c285e2b0c2526f8d4b82581.tar.gz yuzu-7b81e1e52565ee867c285e2b0c2526f8d4b82581.tar.xz yuzu-7b81e1e52565ee867c285e2b0c2526f8d4b82581.zip | |
Merge pull request #1365 from DarkLordZach/lfs
file_sys: Add support for LayeredFS mods
Diffstat (limited to 'src/core/file_sys/romfs.cpp')
| -rw-r--r-- | src/core/file_sys/romfs.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 9f6e41cdf..205284a4d 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.h" | ||
| 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, RomFSExtractionType type) { |
| 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,22 @@ 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().empty()) { |
| 121 | out = out->GetSubdirectory(""); | 123 | if (out->GetSubdirectories().front()->GetName() == "data" && |
| 124 | type == RomFSExtractionType::Truncated) | ||
| 125 | break; | ||
| 126 | out = out->GetSubdirectories().front(); | ||
| 127 | } | ||
| 122 | 128 | ||
| 123 | return out; | 129 | return out; |
| 124 | } | 130 | } |
| 131 | |||
| 132 | VirtualFile CreateRomFS(VirtualDir dir) { | ||
| 133 | if (dir == nullptr) | ||
| 134 | return nullptr; | ||
| 135 | |||
| 136 | RomFSBuildContext ctx{dir}; | ||
| 137 | return ConcatenateFiles<0>(ctx.Build(), dir->GetName()); | ||
| 138 | } | ||
| 139 | |||
| 125 | } // namespace FileSys | 140 | } // namespace FileSys |