Only open file once when detecting blob type

This commit is contained in:
JosJuice
2016-12-21 11:30:12 +01:00
parent 3fdcbbdd92
commit d1ea00ed88
9 changed files with 40 additions and 61 deletions

View File

@ -83,8 +83,10 @@ bool WbfsFileReader::ReadHeader()
{
// Read hd size info
m_files[0]->file.ReadBytes(&m_header, sizeof(WbfsHeader));
m_header.hd_sector_count = Common::swap32(m_header.hd_sector_count);
if (m_header.magic != WBFS_MAGIC)
return false;
m_header.hd_sector_count = Common::swap32(m_header.hd_sector_count);
m_hd_sector_size = 1ull << m_header.hd_sector_shift;
if (m_size != (m_header.hd_sector_count * m_hd_sector_size))
@ -172,14 +174,4 @@ std::unique_ptr<WbfsFileReader> WbfsFileReader::Create(const std::string& filena
return reader;
}
bool IsWbfsBlob(const std::string& filename)
{
File::IOFile f(filename, "rb");
u8 magic[4] = {0, 0, 0, 0};
f.ReadBytes(&magic, 4);
return (magic[0] == 'W') && (magic[1] == 'B') && (magic[2] == 'F') && (magic[3] == 'S');
}
} // namespace