dont crash when you can't open a scanned fat file
This commit is contained in:
parent
b1891e35a9
commit
cf5ba963c0
|
@ -357,18 +357,21 @@ void build_ListCallback(FsEntry* fs, EListCallbackArg arg)
|
||||||
std::string path = currPath + std::string(1,FS_SEPARATOR) + fname;
|
std::string path = currPath + std::string(1,FS_SEPARATOR) + fname;
|
||||||
|
|
||||||
FILE* inf = fopen(path.c_str(),"rb");
|
FILE* inf = fopen(path.c_str(),"rb");
|
||||||
fseek(inf,0,SEEK_END);
|
if(inf)
|
||||||
long len = ftell(inf);
|
{
|
||||||
fseek(inf,0,SEEK_SET);
|
fseek(inf,0,SEEK_END);
|
||||||
u8 *buf = new u8[len];
|
long len = ftell(inf);
|
||||||
fread(buf,1,len,inf);
|
fseek(inf,0,SEEK_SET);
|
||||||
fclose(inf);
|
u8 *buf = new u8[len];
|
||||||
|
fread(buf,1,len,inf);
|
||||||
|
fclose(inf);
|
||||||
|
|
||||||
EmuFatFile f;
|
EmuFatFile f;
|
||||||
f.open(&currFatFile,fname,EO_RDWR | EO_CREAT);
|
f.open(&currFatFile,fname,EO_RDWR | EO_CREAT);
|
||||||
f.write(buf,len);
|
f.write(buf,len);
|
||||||
f.close();
|
f.close();
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue