[Kernel] Read STFS headers for unpackaged files from [path].headers

This commit is contained in:
emoose 2019-07-23 08:40:37 +01:00
parent cb8d23aa08
commit ab9dab806d
No known key found for this signature in database
GPG Key ID: 3735C67912F5FF97
1 changed files with 14 additions and 6 deletions

View File

@ -130,14 +130,22 @@ std::vector<XCONTENT_DATA> ContentManager::ListContent(uint32_t device_id,
content_data.display_name = file_info.name;
content_data.file_name = xe::to_string(file_info.name);
if (file_info.type != xe::filesystem::FileInfo::Type::kDirectory) {
// Not a directory so must be a package, verify size to make sure
if (file_info.total_size <= vfs::StfsHeader::kHeaderLength) {
continue; // Invalid package (maybe .headers file)
auto headers_path = file_info.path + file_info.name;
if (file_info.type == xe::filesystem::FileInfo::Type::kDirectory) {
headers_path = headers_path + L".headers";
}
if (xe::filesystem::PathExists(headers_path)) {
// File is either package or directory that has .headers file
if (file_info.type != xe::filesystem::FileInfo::Type::kDirectory) {
// Not a directory so must be a package, verify size to make sure
if (file_info.total_size <= vfs::StfsHeader::kHeaderLength) {
continue; // Invalid package (maybe .headers file)
}
}
auto map = MappedMemory::Open(file_info.path + file_info.name,
MappedMemory::Mode::kRead, 0,
auto map = MappedMemory::Open(headers_path, MappedMemory::Mode::kRead, 0,
vfs::StfsHeader::kHeaderLength);
if (map) {
vfs::StfsHeader header;