DiscIO: Use std::optional in Volume and Blob

This commit is contained in:
JosJuice
2017-06-04 10:33:14 +02:00
parent e23cfc2965
commit c3fa0d6edf
23 changed files with 232 additions and 237 deletions

View File

@ -7,6 +7,7 @@
#include <locale>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
@ -29,11 +30,11 @@ CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader) : m_reader(std::move
_assert_(m_reader);
// Source: http://wiibrew.org/wiki/WAD_files
m_reader->ReadSwapped(0x00, &m_hdr_size);
m_reader->ReadSwapped(0x08, &m_cert_size);
m_reader->ReadSwapped(0x10, &m_tick_size);
m_reader->ReadSwapped(0x14, &m_tmd_size);
m_reader->ReadSwapped(0x18, &m_data_size);
m_hdr_size = m_reader->ReadSwapped<u32>(0x00).value_or(0);
m_cert_size = m_reader->ReadSwapped<u32>(0x08).value_or(0);
m_tick_size = m_reader->ReadSwapped<u32>(0x10).value_or(0);
m_tmd_size = m_reader->ReadSwapped<u32>(0x14).value_or(0);
m_data_size = m_reader->ReadSwapped<u32>(0x18).value_or(0);
m_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40);
m_tmd_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40) +
@ -109,16 +110,13 @@ std::string CVolumeWAD::GetMakerID(const Partition& partition) const
std::optional<u64> CVolumeWAD::GetTitleID(const Partition& partition) const
{
u64 title_id;
if (!ReadSwapped(m_offset + 0x01DC, &title_id, partition))
return {};
return title_id;
return ReadSwapped<u64>(m_offset + 0x01DC, partition);
}
u16 CVolumeWAD::GetRevision(const Partition& partition) const
std::optional<u16> CVolumeWAD::GetRevision(const Partition& partition) const
{
if (!m_tmd.IsValid())
return 0;
return {};
return m_tmd.GetTitleVersion();
}