diff options
| author | 2018-09-19 22:02:44 -0400 | |
|---|---|---|
| committer | 2018-09-21 19:53:33 -0400 | |
| commit | 16188acb500cb238281dff28d944008ea56eb81b (patch) | |
| tree | 882bc62991b96775e7958ae9a9ce57877fc817ae /src/core/file_sys | |
| parent | vfs_concat: Rewrite and fix ConcatenatedVfsFile (diff) | |
| download | yuzu-16188acb500cb238281dff28d944008ea56eb81b.tar.gz yuzu-16188acb500cb238281dff28d944008ea56eb81b.tar.xz yuzu-16188acb500cb238281dff28d944008ea56eb81b.zip | |
patch_manager: Add LayeredFS mods support
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 43 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 2 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index aebc69d52..74a0acf1a 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "core/file_sys/patch_manager.h" | 11 | #include "core/file_sys/patch_manager.h" |
| 12 | #include "core/file_sys/registered_cache.h" | 12 | #include "core/file_sys/registered_cache.h" |
| 13 | #include "core/file_sys/romfs.h" | 13 | #include "core/file_sys/romfs.h" |
| 14 | #include "core/file_sys/vfs_layered.h" | ||
| 14 | #include "core/hle/service/filesystem/filesystem.h" | 15 | #include "core/hle/service/filesystem/filesystem.h" |
| 15 | #include "core/loader/loader.h" | 16 | #include "core/loader/loader.h" |
| 16 | 17 | ||
| @@ -31,8 +32,9 @@ std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { | |||
| 31 | return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); | 32 | return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | constexpr std::array<const char*, 1> PATCH_TYPE_NAMES{ | 35 | constexpr std::array<const char*, 2> PATCH_TYPE_NAMES{ |
| 35 | "Update", | 36 | "Update", |
| 37 | "LayeredFS", | ||
| 36 | }; | 38 | }; |
| 37 | 39 | ||
| 38 | std::string FormatPatchTypeName(PatchType type) { | 40 | std::string FormatPatchTypeName(PatchType type) { |
| @@ -89,6 +91,41 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, | |||
| 89 | } | 91 | } |
| 90 | } | 92 | } |
| 91 | 93 | ||
| 94 | // LayeredFS | ||
| 95 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | ||
| 96 | if (type == ContentRecordType::Program && load_dir != nullptr && load_dir->GetSize() > 0) { | ||
| 97 | const auto extracted = ExtractRomFS(romfs); | ||
| 98 | |||
| 99 | if (extracted != nullptr) { | ||
| 100 | auto patch_dirs = load_dir->GetSubdirectories(); | ||
| 101 | std::sort(patch_dirs.begin(), patch_dirs.end(), | ||
| 102 | [](const VirtualDir& l, const VirtualDir& r) { | ||
| 103 | return l->GetName() < r->GetName(); | ||
| 104 | }); | ||
| 105 | |||
| 106 | std::vector<VirtualDir> layers; | ||
| 107 | layers.reserve(patch_dirs.size() + 1); | ||
| 108 | for (const auto& subdir : patch_dirs) { | ||
| 109 | const auto romfs_dir = subdir->GetSubdirectory("romfs"); | ||
| 110 | if (romfs_dir != nullptr) | ||
| 111 | layers.push_back(romfs_dir); | ||
| 112 | } | ||
| 113 | |||
| 114 | layers.push_back(extracted); | ||
| 115 | |||
| 116 | const auto layered = LayerDirectories(layers); | ||
| 117 | |||
| 118 | if (layered != nullptr) { | ||
| 119 | const auto packed = CreateRomFS(layered); | ||
| 120 | |||
| 121 | if (packed != nullptr) { | ||
| 122 | LOG_INFO(Loader, " RomFS: LayeredFS patches applied successfully"); | ||
| 123 | romfs = packed; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 92 | return romfs; | 129 | return romfs; |
| 93 | } | 130 | } |
| 94 | 131 | ||
| @@ -114,6 +151,10 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const { | |||
| 114 | } | 151 | } |
| 115 | } | 152 | } |
| 116 | 153 | ||
| 154 | const auto lfs_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | ||
| 155 | if (lfs_dir != nullptr && lfs_dir->GetSize() > 0) | ||
| 156 | out[PatchType::LayeredFS] = ""; | ||
| 157 | |||
| 117 | return out; | 158 | return out; |
| 118 | } | 159 | } |
| 119 | 160 | ||
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 209cab1dc..464f17515 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h | |||
| @@ -26,6 +26,7 @@ std::string FormatTitleVersion(u32 version, | |||
| 26 | 26 | ||
| 27 | enum class PatchType { | 27 | enum class PatchType { |
| 28 | Update, | 28 | Update, |
| 29 | LayeredFS, | ||
| 29 | }; | 30 | }; |
| 30 | 31 | ||
| 31 | std::string FormatPatchTypeName(PatchType type); | 32 | std::string FormatPatchTypeName(PatchType type); |
| @@ -42,6 +43,7 @@ public: | |||
| 42 | 43 | ||
| 43 | // Currently tracked RomFS patches: | 44 | // Currently tracked RomFS patches: |
| 44 | // - Game Updates | 45 | // - Game Updates |
| 46 | // - LayeredFS | ||
| 45 | VirtualFile PatchRomFS(VirtualFile base, u64 ivfc_offset, | 47 | VirtualFile PatchRomFS(VirtualFile base, u64 ivfc_offset, |
| 46 | ContentRecordType type = ContentRecordType::Program) const; | 48 | ContentRecordType type = ContentRecordType::Program) const; |
| 47 | 49 | ||