fix memory card saves

This commit is contained in:
dborth 2009-04-09 07:41:37 +00:00
parent 993a3eb00f
commit e0f60f7ba6
2 changed files with 27 additions and 20 deletions

View File

@ -218,8 +218,20 @@ bool MakeFilePath(char filepath[], int type, int method, char * filename, int fi
{
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
{
filename[26] = 0; // truncate filename
sprintf(file, "%s%i.%s", filename, filenum, ext);
if(filenum > 9)
{
return false;
}
else if(filenum == -1)
{
filename[27] = 0; // truncate filename
sprintf(file, "%s.%s", filename, ext);
}
else
{
filename[26] = 0; // truncate filename
sprintf(file, "%s%i.%s", filename, filenum, ext);
}
}
else
{

View File

@ -325,27 +325,22 @@ bool LoadBatteryOrStateAuto(int method, int action, bool silent)
if (action==FILE_SRAM)
{
if (!LoadBatteryOrState(filepath, method, action, SILENT))
{
if(!MakeFilePath(filepath2, action, method, ROMFilename, -1))
return false;
if(LoadBatteryOrState(filepath2, method, action, silent))
{
// rename this file - append Auto
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to path
sprintf(fullpath2, "%s%s", rootdir, filepath2); // add device to path
rename(fullpath2, fullpath); // rename file (to avoid duplicates)
return true;
}
else
{
return false;
}
}
else
if (LoadBatteryOrState(filepath, method, action, SILENT))
return true;
// look for file with no number or Auto appended
if(!MakeFilePath(filepath2, action, method, ROMFilename, -1))
return false;
if(LoadBatteryOrState(filepath2, method, action, silent))
{
// rename this file - append Auto
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to path
sprintf(fullpath2, "%s%s", rootdir, filepath2); // add device to path
rename(fullpath2, fullpath); // rename file (to avoid duplicates)
return true;
}
return false;
}
else
{