Merge pull request #4247 from lioncash/wad

WiiWad: Minor changes
This commit is contained in:
Markus Wick 2016-09-27 12:37:02 +02:00 committed by GitHub
commit 3de4dc2186
2 changed files with 30 additions and 29 deletions

View File

@ -16,6 +16,34 @@
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)
{
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)
{
CBlobBigEndianReader big_endian_reader(reader);
@ -88,13 +100,4 @@ bool WiiWAD::ParseWAD(IBlobReader& reader)
return true;
}
bool WiiWAD::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);
}
} // namespace end
} // namespace DiscIO

View File

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