summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/patch_manager.cpp30
-rw-r--r--src/core/file_sys/patch_manager.h1
-rw-r--r--src/core/file_sys/romfs_factory.cpp51
3 files changed, 55 insertions, 27 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 4b3b5e665..57b7741f8 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
#include <array>
#include <cstddef>
@@ -18,6 +19,7 @@
namespace FileSys {
constexpr u64 SINGLE_BYTE_MODULUS = 0x100;
+constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
std::string FormatTitleVersion(u32 version, TitleVersionFormat format) {
std::array<u8, sizeof(u32)> bytes{};
@@ -32,9 +34,10 @@ std::string FormatTitleVersion(u32 version, TitleVersionFormat format) {
return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]);
}
-constexpr std::array<const char*, 2> PATCH_TYPE_NAMES{
+constexpr std::array<const char*, 3> PATCH_TYPE_NAMES{
"Update",
"LayeredFS",
+ "DLC",
};
std::string FormatPatchTypeName(PatchType type) {
@@ -139,6 +142,7 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const {
std::map<PatchType, std::string> out;
const auto installed = Service::FileSystem::GetUnionContents();
+ // Game Updates
const auto update_tid = GetUpdateTitleID(title_id);
PatchManager update{update_tid};
auto [nacp, discard_icon_file] = update.GetControlMetadata();
@@ -157,10 +161,34 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const {
}
}
+ // LayeredFS
const auto lfs_dir = Service::FileSystem::GetModificationLoadRoot(title_id);
if (lfs_dir != nullptr && lfs_dir->GetSize() > 0)
out.insert_or_assign(PatchType::LayeredFS, "");
+ // DLC
+ const auto dlc_entries = installed->ListEntriesFilter(TitleType::AOC, ContentRecordType::Data);
+ std::vector<RegisteredCacheEntry> dlc_match;
+ dlc_match.reserve(dlc_entries.size());
+ std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match),
+ [this, &installed](const RegisteredCacheEntry& entry) {
+ return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id &&
+ installed->GetEntry(entry)->GetStatus() ==
+ Loader::ResultStatus::Success;
+ });
+ if (!dlc_match.empty()) {
+ // Ensure sorted so DLC IDs show in order.
+ std::sort(dlc_match.begin(), dlc_match.end());
+
+ std::string list;
+ for (size_t i = 0; i < dlc_match.size() - 1; ++i)
+ list += fmt::format("{}, ", dlc_match[i].title_id & 0x7FF);
+
+ list += fmt::format("{}", dlc_match.back().title_id & 0x7FF);
+
+ out.insert_or_assign(PatchType::DLC, std::move(list));
+ }
+
return out;
}
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h
index 464f17515..3a2a9d212 100644
--- a/src/core/file_sys/patch_manager.h
+++ b/src/core/file_sys/patch_manager.h
@@ -27,6 +27,7 @@ std::string FormatTitleVersion(u32 version,
enum class PatchType {
Update,
LayeredFS,
+ DLC,
};
std::string FormatPatchTypeName(PatchType type);
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index d027a8d59..4994c2532 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -39,36 +39,35 @@ ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
}
ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) {
+ std::shared_ptr<NCA> res;
+
switch (storage) {
- case StorageId::NandSystem: {
- const auto res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type);
- if (res == nullptr) {
- // TODO(DarkLordZach): Find the right error code to use here
- return ResultCode(-1);
- }
- const auto romfs = res->GetRomFS();
- if (romfs == nullptr) {
- // TODO(DarkLordZach): Find the right error code to use here
- return ResultCode(-1);
- }
- return MakeResult<VirtualFile>(romfs);
- }
- case StorageId::NandUser: {
- const auto res = Service::FileSystem::GetUserNANDContents()->GetEntry(title_id, type);
- if (res == nullptr) {
- // TODO(DarkLordZach): Find the right error code to use here
- return ResultCode(-1);
- }
- const auto romfs = res->GetRomFS();
- if (romfs == nullptr) {
- // TODO(DarkLordZach): Find the right error code to use here
- return ResultCode(-1);
- }
- return MakeResult<VirtualFile>(romfs);
- }
+ case StorageId::None:
+ res = Service::FileSystem::GetUnionContents()->GetEntry(title_id, type);
+ break;
+ case StorageId::NandSystem:
+ res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type);
+ break;
+ case StorageId::NandUser:
+ res = Service::FileSystem::GetUserNANDContents()->GetEntry(title_id, type);
+ break;
+ case StorageId::SdCard:
+ res = Service::FileSystem::GetSDMCContents()->GetEntry(title_id, type);
+ break;
default:
UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage));
}
+
+ if (res == nullptr) {
+ // TODO(DarkLordZach): Find the right error code to use here
+ return ResultCode(-1);
+ }
+ const auto romfs = res->GetRomFS();
+ if (romfs == nullptr) {
+ // TODO(DarkLordZach): Find the right error code to use here
+ return ResultCode(-1);
+ }
+ return MakeResult<VirtualFile>(romfs);
}
} // namespace FileSys