IsElfWii(): return false if open fails. Also query file size only once.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@324 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Maarten ter Huurne 2008-08-26 13:02:54 +00:00
parent ef6fb30b3c
commit 19336445df
1 changed files with 6 additions and 4 deletions

View File

@ -7,10 +7,12 @@
bool CBoot::IsElfWii(const char *filename)
{
Common::IMappedFile *mapfile = Common::IMappedFile::CreateMappedFile();
mapfile->Open(filename);
u8 *ptr = mapfile->Lock(0, mapfile->GetSize());
u8 *mem = new u8[(size_t)mapfile->GetSize()];
memcpy(mem, ptr, (size_t)mapfile->GetSize());
bool ok = mapfile->Open(filename);
if (!ok) return false;
size_t filesize = mapfile->GetSize();
u8 *ptr = mapfile->Lock(0, filesize);
u8 *mem = new u8[filesize];
memcpy(mem, ptr, filesize);
mapfile->Unlock(ptr);
mapfile->Close();