[Kernel] CreateContent: create headers.bin file with the content info

This commit is contained in:
emoose 2020-01-11 18:22:13 +00:00
parent 15307fae4d
commit d3065fd694
1 changed files with 19 additions and 1 deletions

View File

@ -112,7 +112,8 @@ std::vector<XCONTENT_DATA> ContentManager::ListContent(uint32_t device_id,
auto* header = (vfs::StfsHeader*)map->data();
content_data.content_type =
static_cast<uint32_t>(header->metadata.content_type);
content_data.display_name = header->metadata.display_name[0];
content_data.display_name =
header->metadata.get_display_name(XLanguage::kEnglish);
// TODO: select localized display name
// some games may expect different ones depending on language setting.
map->Close();
@ -184,6 +185,23 @@ X_RESULT ContentManager::CreateContent(std::string root_name,
return X_ERROR_FUNCTION_FAILED; // Failed to create directory?
}
// Create .headers.bin file
auto headers_path = package_path + ContentManager::kStfsHeadersExtension;
auto* file = xe::filesystem::OpenFile(headers_path, "wb");
if (!file) {
return X_ERROR_FUNCTION_FAILED; // failed to create headers file :(
}
// Set headers using data from XCONTENT_DATA
vfs::StfsHeader* header = new vfs::StfsHeader();
// TODO: set title_id, title_name & publisher from XDBF info
header->metadata.content_type = (xe::vfs::XContentType)data.content_type;
header->metadata.set_display_name(data.display_name, XLanguage::kEnglish);
// TODO: set display name locale that's currently in use
fwrite(header, sizeof(vfs::StfsHeader), 1, file);
fclose(file);
delete header;
if (!package->Mount(root_name)) {
return X_ERROR_DEVICE_NOT_CONNECTED;
}