mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 15:19:42 -06:00
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:
@ -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();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user