mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-03 00:38:58 +00:00
Change CIA building to be TMD-oriented
... just like how it should be.
This commit is contained in:
@@ -80,6 +80,10 @@ bool CIABuilder::Init(CIABuildType type_, const std::string& destination, TitleM
|
|||||||
header = {};
|
header = {};
|
||||||
meta = {};
|
meta = {};
|
||||||
|
|
||||||
|
if (!FileUtil::CreateFullPath(destination)) {
|
||||||
|
LOG_ERROR(Core, "Could not create {}", destination);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
file = std::make_shared<HashedFile>(destination, "wb");
|
file = std::make_shared<HashedFile>(destination, "wb");
|
||||||
if (!*file) {
|
if (!*file) {
|
||||||
LOG_ERROR(Core, "Could not open file {}", destination);
|
LOG_ERROR(Core, "Could not open file {}", destination);
|
||||||
@@ -342,6 +346,7 @@ bool CIABuilder::AddContent(u16 content_id, NCCHContainer& ncch) {
|
|||||||
std::memcpy(meta.dependencies.data(), &ncch.exheader_header.dependency_list,
|
std::memcpy(meta.dependencies.data(), &ncch.exheader_header.dependency_list,
|
||||||
sizeof(meta.dependencies));
|
sizeof(meta.dependencies));
|
||||||
|
|
||||||
|
// Note: GodMode9 has this hardcoded to 2.
|
||||||
meta.core_version = ncch.exheader_header.arm11_system_local_caps.core_version;
|
meta.core_version = ncch.exheader_header.arm11_system_local_caps.core_version;
|
||||||
|
|
||||||
std::vector<u8> smdh_buffer;
|
std::vector<u8> smdh_buffer;
|
||||||
|
|||||||
+19
-38
@@ -676,8 +676,8 @@ bool SDMCImporter::BuildCIA(CIABuildType build_type, const ContentSpecifier& spe
|
|||||||
std::string destination, const Common::ProgressCallback& callback,
|
std::string destination, const Common::ProgressCallback& callback,
|
||||||
bool auto_filename) {
|
bool auto_filename) {
|
||||||
|
|
||||||
if (config.certs_db_path.empty()) {
|
if (!Certs::IsLoaded()) {
|
||||||
LOG_ERROR(Core, "Missing certs.db");
|
LOG_ERROR(Core, "Missing certs");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,48 +735,29 @@ bool SDMCImporter::BuildCIA(CIABuildType build_type, const ContentSpecifier& spe
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FileUtil::DirectoryEntryCallable DirectoryEntryCallback =
|
for (const auto& tmd_chunk : tmd.tmd_chunks) {
|
||||||
[this, tmd, is_nand, specifier, &DirectoryEntryCallback](u64* /*num_entries_out*/,
|
const auto path =
|
||||||
const std::string& directory,
|
fmt::format("{}{:08x}.app", physical_path, static_cast<u32>(tmd_chunk.id));
|
||||||
const std::string& virtual_name) {
|
if (!FileUtil::Exists(path)) {
|
||||||
if (FileUtil::IsDirectory(directory + virtual_name + "/")) {
|
LOG_ERROR(Core, "Content {:08x} does not exist", static_cast<u32>(tmd_chunk.id));
|
||||||
if (virtual_name == "cmd") {
|
ret = false;
|
||||||
return true; // Skip cmd (not used in Citra)
|
return false;
|
||||||
}
|
|
||||||
// Recursive call (necessary for DLCs)
|
|
||||||
return FileUtil::ForeachDirectoryEntry(nullptr, directory + virtual_name + "/",
|
|
||||||
DirectoryEntryCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::regex app_regex{"([0-9a-f]{8})\\.app"};
|
|
||||||
|
|
||||||
std::smatch match;
|
|
||||||
if (!std::regex_match(virtual_name, match, app_regex)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ASSERT(match.size() >= 2);
|
|
||||||
|
|
||||||
const u32 id = static_cast<u32>(std::stoul(match[1], nullptr, 16));
|
|
||||||
if (!tmd.HasContentID(id)) {
|
|
||||||
LOG_WARNING(Core, "Ignoring content {} (not in TMD)", directory + virtual_name);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_nand) {
|
if (is_nand) {
|
||||||
NCCHContainer ncch(
|
NCCHContainer ncch(std::make_shared<FileUtil::IOFile>(path, "rb"));
|
||||||
std::make_shared<FileUtil::IOFile>(directory + virtual_name, "rb"));
|
ret = cia_builder->AddContent(tmd_chunk.id, ncch);
|
||||||
return cia_builder->AddContent(id, ncch);
|
|
||||||
} else {
|
} else {
|
||||||
const auto relative_path =
|
const auto relative_path = path.substr(config.sdmc_path.size() - 1);
|
||||||
directory.substr(config.sdmc_path.size() - 1) + virtual_name;
|
NCCHContainer ncch(std::make_shared<SDMCFile>(config.sdmc_path, relative_path, "rb"));
|
||||||
NCCHContainer ncch(
|
ret = cia_builder->AddContent(tmd_chunk.id, ncch);
|
||||||
std::make_shared<SDMCFile>(config.sdmc_path, relative_path, "rb"));
|
}
|
||||||
return cia_builder->AddContent(id, ncch);
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
ret = FileUtil::ForeachDirectoryEntry(nullptr, physical_path, DirectoryEntryCallback) &&
|
ret = cia_builder->Finalize();
|
||||||
cia_builder->Finalize();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user