[Emulator] Install Content: Create header for installed packages
This fixes support for certain DLCs
This commit is contained in:
@@ -856,5 +856,31 @@ bool StfsContainerDevice::ResolveFromFolder(const std::filesystem::path& path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
kernel::xam::XCONTENT_AGGREGATE_DATA StfsContainerDevice::content_header() const {
|
||||
kernel::xam::XCONTENT_AGGREGATE_DATA data;
|
||||
|
||||
std::memset(&data, 0, sizeof(kernel::xam::XCONTENT_AGGREGATE_DATA));
|
||||
|
||||
data.device_id = 1;
|
||||
data.title_id = header_.metadata.execution_info.title_id;
|
||||
data.content_type = header_.metadata.content_type;
|
||||
|
||||
auto name = header_.metadata.display_name(XLanguage::kEnglish);
|
||||
if (name.empty()) {
|
||||
// Find first filled language and use it. It might be incorrect, but meh
|
||||
// until stfs support is done.
|
||||
for (uint8_t i = 0; i < header_.metadata.kNumLanguagesV2; i++) {
|
||||
name = header_.metadata.display_name((XLanguage)i);
|
||||
if (!name.empty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.set_display_name(name);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
} // namespace xe
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/string_util.h"
|
||||
#include "xenia/kernel/util/xex2_info.h"
|
||||
#include "xenia/kernel/xam/content_manager.h"
|
||||
#include "xenia/vfs/device.h"
|
||||
#include "xenia/vfs/devices/stfs_xbox.h"
|
||||
|
||||
@@ -86,6 +87,8 @@ class StfsContainerDevice : public Device {
|
||||
uint32_t title_id() const { return header_.metadata.execution_info.title_id; }
|
||||
XContentType content_type() const { return header_.metadata.content_type; }
|
||||
|
||||
kernel::xam::XCONTENT_AGGREGATE_DATA content_header() const;
|
||||
|
||||
private:
|
||||
const uint32_t kBlocksPerHashLevel[3] = {170, 28900, 4913000};
|
||||
const uint32_t kEndOfChain = 0xFFFFFF;
|
||||
|
||||
@@ -45,7 +45,7 @@ int vfs_dump_main(const std::vector<std::string>& args) {
|
||||
XELOGE("Failed to initialize device");
|
||||
return 1;
|
||||
}
|
||||
return VirtualFileSystem::ExtractFiles(device.get(), base_path);
|
||||
return VirtualFileSystem::ExtractContentFiles(device.get(), base_path);
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "xenia/vfs/virtual_file_system.h"
|
||||
#include "xenia/kernel/xam/content_manager.h"
|
||||
#include "xenia/vfs/devices/stfs_container_device.h"
|
||||
|
||||
#include "xenia/base/literals.h"
|
||||
#include "xenia/base/logging.h"
|
||||
@@ -310,8 +312,8 @@ X_STATUS VirtualFileSystem::OpenFile(Entry* root_entry,
|
||||
return result;
|
||||
}
|
||||
|
||||
X_STATUS VirtualFileSystem::ExtractFiles(Device* device,
|
||||
std::filesystem::path base_path) {
|
||||
X_STATUS VirtualFileSystem::ExtractContentFiles(
|
||||
Device* device, std::filesystem::path base_path) {
|
||||
// Run through all the files, breadth-first style.
|
||||
std::queue<vfs::Entry*> queue;
|
||||
auto root = device->ResolvePath("/");
|
||||
@@ -382,5 +384,28 @@ X_STATUS VirtualFileSystem::ExtractFiles(Device* device,
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void VirtualFileSystem::ExtractContentHeader(Device* device,
|
||||
std::filesystem::path base_path) {
|
||||
auto stfs_device = ((StfsContainerDevice*)device);
|
||||
|
||||
if (!std::filesystem::exists(base_path.parent_path())) {
|
||||
if (!std::filesystem::create_directories(base_path.parent_path())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto header_filename = base_path.filename().string() + ".header";
|
||||
auto header_path = base_path.parent_path() / header_filename;
|
||||
xe::filesystem::CreateEmptyFile(header_path);
|
||||
|
||||
if (std::filesystem::exists(header_path)) {
|
||||
auto file = xe::filesystem::OpenFile(header_path, "wb");
|
||||
kernel::xam::XCONTENT_AGGREGATE_DATA data = stfs_device->content_header();
|
||||
data.set_file_name(base_path.filename().string());
|
||||
fwrite(&data, 1, sizeof(kernel::xam::XCONTENT_AGGREGATE_DATA), file);
|
||||
fclose(file);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} // namespace vfs
|
||||
} // namespace xe
|
||||
|
||||
@@ -47,7 +47,11 @@ class VirtualFileSystem {
|
||||
bool is_non_directory, File** out_file,
|
||||
FileAction* out_action);
|
||||
|
||||
static X_STATUS ExtractFiles(Device* device, std::filesystem::path base_path);
|
||||
static X_STATUS ExtractContentFiles(Device* device,
|
||||
std::filesystem::path base_path);
|
||||
static void ExtractContentHeader(Device* device,
|
||||
std::filesystem::path base_path);
|
||||
|
||||
private:
|
||||
xe::global_critical_region global_critical_region_;
|
||||
std::vector<std::unique_ptr<Device>> devices_;
|
||||
|
||||
Reference in New Issue
Block a user