WiiWad: Move static implementation details to cpp file

These functions don't actually depend on any state from the class
instance, so they don't really belong in the header, and are just
an implementation detail.
This commit is contained in:
Lioncash 2016-09-25 17:24:44 -04:00
parent e7efbf7ae5
commit 7de0d51345
2 changed files with 29 additions and 28 deletions

View File

@ -16,6 +16,34 @@
namespace DiscIO namespace DiscIO
{ {
namespace
{
std::vector<u8> CreateWADEntry(IBlobReader& reader, u32 size, u64 offset)
{
if (size == 0)
return {};
std::vector<u8> buffer(size);
if (!reader.Read(offset, size, buffer.data()))
{
ERROR_LOG(DISCIO, "WiiWAD: Could not read from file");
PanicAlertT("WiiWAD: Could not read from file");
}
return buffer;
}
bool IsWiiWAD(const CBlobBigEndianReader& reader)
{
u32 header_size = 0;
u32 header_type = 0;
reader.ReadSwapped(0x0, &header_size);
reader.ReadSwapped(0x4, &header_type);
return header_size == 0x20 && (header_type == 0x49730000 || header_type == 0x69620000);
}
} // Anonymous namespace
WiiWAD::WiiWAD(const std::string& name) WiiWAD::WiiWAD(const std::string& name)
{ {
std::unique_ptr<IBlobReader> reader(CreateBlobReader(name)); std::unique_ptr<IBlobReader> reader(CreateBlobReader(name));
@ -32,22 +60,6 @@ WiiWAD::~WiiWAD()
{ {
} }
std::vector<u8> WiiWAD::CreateWADEntry(IBlobReader& reader, u32 size, u64 offset)
{
if (size == 0)
return {};
std::vector<u8> buffer(size);
if (!reader.Read(offset, size, buffer.data()))
{
ERROR_LOG(DISCIO, "WiiWAD: Could not read from file");
PanicAlertT("WiiWAD: Could not read from file");
}
return buffer;
}
bool WiiWAD::ParseWAD(IBlobReader& reader) bool WiiWAD::ParseWAD(IBlobReader& reader)
{ {
CBlobBigEndianReader big_endian_reader(reader); CBlobBigEndianReader big_endian_reader(reader);
@ -88,13 +100,4 @@ bool WiiWAD::ParseWAD(IBlobReader& reader)
return true; return true;
} }
bool WiiWAD::IsWiiWAD(const CBlobBigEndianReader& reader) } // namespace DiscIO
{
u32 header_size = 0;
u32 header_type = 0;
reader.ReadSwapped(0x0, &header_size);
reader.ReadSwapped(0x4, &header_type);
return header_size == 0x20 && (header_type == 0x49730000 || header_type == 0x69620000);
}
} // namespace end

View File

@ -28,8 +28,6 @@ public:
const std::vector<u8>& GetFooter() const { return m_footer; } const std::vector<u8>& GetFooter() const { return m_footer; }
private: private:
bool ParseWAD(IBlobReader& reader); bool ParseWAD(IBlobReader& reader);
static std::vector<u8> CreateWADEntry(IBlobReader& reader, u32 size, u64 offset);
static bool IsWiiWAD(const CBlobBigEndianReader& reader);
bool m_valid; bool m_valid;