mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
DiscIO/DirectoryBlob: Add ability to have a start-of-file offset for a file ContentSource.
This commit is contained in:
@ -97,11 +97,15 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const
|
||||
{
|
||||
const u64 bytes_to_read = std::min(m_size - offset_in_content, *length);
|
||||
|
||||
if (std::holds_alternative<std::string>(m_content_source))
|
||||
if (std::holds_alternative<ContentFile>(m_content_source))
|
||||
{
|
||||
File::IOFile file(std::get<std::string>(m_content_source), "rb");
|
||||
if (!file.Seek(offset_in_content, SEEK_SET) || !file.ReadBytes(*buffer, bytes_to_read))
|
||||
const auto& content = std::get<ContentFile>(m_content_source);
|
||||
File::IOFile file(content.m_filename, "rb");
|
||||
if (!file.Seek(content.m_offset + offset_in_content, SEEK_SET) ||
|
||||
!file.ReadBytes(*buffer, bytes_to_read))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (std::holds_alternative<const u8*>(m_content_source))
|
||||
{
|
||||
@ -136,14 +140,14 @@ void DiscContentContainer::Add(u64 offset, u64 size, ContentSource source)
|
||||
u64 DiscContentContainer::CheckSizeAndAdd(u64 offset, const std::string& path)
|
||||
{
|
||||
const u64 size = File::GetSize(path);
|
||||
Add(offset, size, path);
|
||||
Add(offset, size, ContentFile{path, 0});
|
||||
return size;
|
||||
}
|
||||
|
||||
u64 DiscContentContainer::CheckSizeAndAdd(u64 offset, u64 max_size, const std::string& path)
|
||||
{
|
||||
const u64 size = std::min(File::GetSize(path), max_size);
|
||||
Add(offset, size, path);
|
||||
Add(offset, size, ContentFile{path, 0});
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -791,7 +795,7 @@ void DirectoryBlobPartition::WriteDirectory(const File::FSTEntry& parent_entry,
|
||||
WriteEntryName(name_offset, entry.virtualName, name_table_offset);
|
||||
|
||||
// write entry to virtual disc
|
||||
m_contents.Add(*data_offset, entry.size, entry.physicalName);
|
||||
m_contents.Add(*data_offset, entry.size, ContentFile{entry.physicalName, 0});
|
||||
|
||||
// 32 KiB aligned - many games are fine with less alignment, but not all
|
||||
*data_offset = Common::AlignUp(*data_offset + entry.size, 0x8000ull);
|
||||
|
Reference in New Issue
Block a user