Only try to load cheats file if we got a valid string back from

MDFN_MakeFName
This commit is contained in:
twinaphex 2014-06-17 01:20:56 +02:00
parent 7c59861979
commit 3a74c5c848
3 changed files with 13 additions and 20 deletions

View File

@ -37,12 +37,7 @@
FileStream::FileStream(const char *path, const int mode): OpenedMode(mode)
{
if(mode == FileStream::MODE_WRITE)
fp = fopen(path, "wb");
else
fp = fopen(path, "rb");
if(!fp)
if(!(fp = fopen(path, (mode == FileStream::MODE_WRITE) ? "wb" : "rb")))
{
ErrnoHolder ene(errno);
@ -92,8 +87,7 @@ int64 FileStream::tell(void)
return ftello(fp);
}
int64 FileStream::size(void)
{
int64 FileStream::size(void) {
struct stat buf;
fstat(fileno(fp), &buf);

View File

@ -40,12 +40,7 @@
FileWrapper::FileWrapper(const char *path, const int mode, const char *purpose) : OpenedMode(mode)
{
if(mode == MODE_WRITE)
fp = fopen(path, "wb");
else
fp = fopen(path, "rb");
if(!fp)
if(!(fp = fopen(path, (mode == MODE_WRITE) ? "wb" : "rb")))
{
ErrnoHolder ene(errno);

View File

@ -238,15 +238,19 @@ void MDFN_LoadGameCheats(void *override_ptr)
{
const char *fn = MDFN_MakeFName(MDFNMKF_CHEAT,0,0).c_str();
if (log_cb && fn)
if (log_cb && fn[0] != '\0')
{
log_cb(RETRO_LOG_INFO, "Loading cheats from %s...\n", fn);
if(!(fp = fopen(fn,"rb")))
{
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Error opening file.\n");
return;
if(!(fp = fopen(fn,"rb")))
{
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Error opening file.\n");
return;
}
}
else
return;
}
if(SeekToOurSection(fp))