mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-26 12:56:54 +01:00
Add add-on (DLC) support (#1519)
Add add-on content support Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#include "loader/additionalContent.h"
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
|
||||
namespace Loader {
|
||||
|
||||
static std::vector<AddContentEntry> g_add_content;
|
||||
|
||||
void AddContentLoad(const std::filesystem::path& dir, const std::string& title_id) {
|
||||
g_add_content = Common::FindAddContent(dir, title_id);
|
||||
for (const auto& entry: g_add_content) {
|
||||
LOGF("AddContent: registered %s -> %s\n", entry.content_id.c_str(),
|
||||
Common::PathToString(entry.mount_dir).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<AddContentEntry>& AddContentGetAll() {
|
||||
return g_add_content;
|
||||
}
|
||||
|
||||
const AddContentEntry* AddContentFind(const char* label, size_t label_size) {
|
||||
if (label == nullptr || label_size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
const std::string_view value(label, std::find(label, label + label_size, '\0') - label);
|
||||
const auto it =
|
||||
std::find_if(g_add_content.begin(), g_add_content.end(),
|
||||
[&](const auto& entry) { return entry.entitlement_label == value; });
|
||||
return it == g_add_content.end() ? nullptr : &*it;
|
||||
}
|
||||
|
||||
} // namespace Loader
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef EMULATOR_INCLUDE_EMULATOR_LOADER_ADDITIONAL_CONTENT_H_
|
||||
#define EMULATOR_INCLUDE_EMULATOR_LOADER_ADDITIONAL_CONTENT_H_
|
||||
|
||||
#include "common/additionalContent.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace Loader {
|
||||
|
||||
using AddContentEntry = Common::AddContentEntry;
|
||||
|
||||
void AddContentLoad(const std::filesystem::path& dir, const std::string& title_id);
|
||||
const std::vector<AddContentEntry>& AddContentGetAll();
|
||||
const AddContentEntry* AddContentFind(const char* label, size_t label_size);
|
||||
|
||||
} // namespace Loader
|
||||
|
||||
#endif /* EMULATOR_INCLUDE_EMULATOR_LOADER_ADDITIONAL_CONTENT_H_ */
|
||||
Reference in New Issue
Block a user