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:
parent
ef6fb30b3c
commit
19336445df
|
@ -7,10 +7,12 @@
|
||||||
bool CBoot::IsElfWii(const char *filename)
|
bool CBoot::IsElfWii(const char *filename)
|
||||||
{
|
{
|
||||||
Common::IMappedFile *mapfile = Common::IMappedFile::CreateMappedFile();
|
Common::IMappedFile *mapfile = Common::IMappedFile::CreateMappedFile();
|
||||||
mapfile->Open(filename);
|
bool ok = mapfile->Open(filename);
|
||||||
u8 *ptr = mapfile->Lock(0, mapfile->GetSize());
|
if (!ok) return false;
|
||||||
u8 *mem = new u8[(size_t)mapfile->GetSize()];
|
size_t filesize = mapfile->GetSize();
|
||||||
memcpy(mem, ptr, (size_t)mapfile->GetSize());
|
u8 *ptr = mapfile->Lock(0, filesize);
|
||||||
|
u8 *mem = new u8[filesize];
|
||||||
|
memcpy(mem, ptr, filesize);
|
||||||
mapfile->Unlock(ptr);
|
mapfile->Unlock(ptr);
|
||||||
mapfile->Close();
|
mapfile->Close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue