DiscIO/DirectoryBlob: Add a content source that reads data from a DiscIO::Volume.
This commit is contained in:
parent
b7a9cc37b1
commit
f8611f7139
|
@ -123,6 +123,15 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const
|
||||||
return false;
|
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
|
else
|
||||||
{
|
{
|
||||||
PanicAlertFmt("DirectoryBlob: Invalid content source in DiscContent.");
|
PanicAlertFmt("DirectoryBlob: Invalid content source in DiscContent.");
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "DiscIO/Blob.h"
|
#include "DiscIO/Blob.h"
|
||||||
|
#include "DiscIO/Volume.h"
|
||||||
#include "DiscIO/WiiEncryptionCache.h"
|
#include "DiscIO/WiiEncryptionCache.h"
|
||||||
|
|
||||||
namespace File
|
namespace File
|
||||||
|
@ -57,9 +58,23 @@ struct ContentPartition
|
||||||
u64 m_partition_data_offset;
|
u64 m_partition_data_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ContentSource = std::variant<ContentFile, // File
|
// Content chunk that loads data from a Volume.
|
||||||
const u8*, // Memory
|
struct ContentVolume
|
||||||
ContentPartition // Partition
|
{
|
||||||
|
// 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
|
class DiscContent
|
||||||
|
|
Loading…
Reference in New Issue