DiscIO/DirectoryBlob: Add a content source that reads data from a DiscIO::Volume.

This commit is contained in:
Admiral H. Curtiss 2021-09-22 02:57:31 +02:00
parent b7a9cc37b1
commit f8611f7139
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 27 additions and 3 deletions

View File

@ -123,6 +123,15 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const
return false;
}
}
else if (std::holds_alternative<ContentVolume>(m_content_source))
{
const auto& source = std::get<ContentVolume>(m_content_source);
if (!source.m_volume->Read(source.m_offset + offset_in_content, bytes_to_read, *buffer,
source.m_partition))
{
return false;
}
}
else
{
PanicAlertFmt("DirectoryBlob: Invalid content source in DiscContent.");

View File

@ -16,6 +16,7 @@
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Volume.h"
#include "DiscIO/WiiEncryptionCache.h"
namespace File
@ -57,9 +58,23 @@ struct ContentPartition
u64 m_partition_data_offset;
};
using ContentSource = std::variant<ContentFile, // File
const u8*, // Memory
ContentPartition // Partition
// Content chunk that loads data from a Volume.
struct ContentVolume
{
// Offset from the start of the volume for the first byte represented by this chunk.
u64 m_offset;
// The volume to read data from.
const Volume* m_volume;
// The partition passed to the Volume's Read() method.
Partition m_partition;
};
using ContentSource = std::variant<ContentFile, // File
const u8*, // Memory
ContentPartition, // Partition
ContentVolume // Volume
>;
class DiscContent