DirectoryBlob: Implement GetDataSize()

This commit is contained in:
JosJuice 2017-06-10 19:07:12 +02:00
parent d84bee3ff4
commit e15b957d53
2 changed files with 14 additions and 2 deletions

View File

@ -29,6 +29,7 @@
#include "Common/Swap.h"
#include "Core/Boot/DolReader.h"
#include "DiscIO/Blob.h"
#include "DiscIO/VolumeWii.h"
namespace DiscIO
{
@ -165,11 +166,16 @@ DirectoryBlobReader::DirectoryBlobReader(const std::string& root_directory)
if (!m_is_wii)
{
m_gamecube_pseudopartition = std::move(game_partition);
m_data_size = m_gamecube_pseudopartition.GetDataSize();
}
else
{
SetNonpartitionDiscHeader(game_partition.GetHeader());
const u64 unaligned_data_size = VolumeWii::PartitionOffsetToRawOffset(
game_partition.GetDataSize(), Partition(GAME_PARTITION_ADDRESS));
m_data_size = Common::AlignUp(unaligned_data_size, 0x8000ull);
m_partitions.emplace(GAME_PARTITION_ADDRESS, std::move(game_partition));
SetPartitionTable();
@ -249,8 +255,7 @@ u64 DirectoryBlobReader::GetRawSize() const
u64 DirectoryBlobReader::GetDataSize() const
{
// Not implemented
return 0;
return m_data_size;
}
void DirectoryBlobReader::SetNonpartitionDiscHeader(const std::vector<u8>& partition_header)
@ -451,6 +456,8 @@ void DirectoryBlobPartition::BuildFST(u64 fst_address)
Write32((u32)(m_fst_data.size() >> m_address_shift), 0x042c, &m_disk_header);
m_contents.emplace(fst_address, m_fst_data.size(), m_fst_data.data());
m_data_size = current_data_address;
}
void DirectoryBlobPartition::WriteEntryData(u32* entry_offset, u8 type, u32 name_offset,

View File

@ -66,6 +66,7 @@ public:
DirectoryBlobPartition& operator=(DirectoryBlobPartition&&) = default;
bool IsWii() const { return m_is_wii; }
u64 GetDataSize() const { return m_data_size; }
const std::vector<u8>& GetHeader() const { return m_disk_header; }
const std::set<DiscContent>& GetContents() const { return m_contents; }
private:
@ -95,6 +96,8 @@ private:
bool m_is_wii = false;
// GameCube has no shift, Wii has 2 bit shift
u32 m_address_shift = 0;
u64 m_data_size;
};
class DirectoryBlobReader : public BlobReader
@ -148,6 +151,8 @@ private:
} m_tmd_header;
static_assert(sizeof(TMDHeader) == 8, "Wrong size for TMDHeader");
#pragma pack(pop)
u64 m_data_size;
};
} // namespace