A little modification on the W32 side - backup savestate before overwriting it.

This commit is contained in:
dinkc64 2014-04-20 14:05:45 +00:00
parent 713833dc4d
commit 80f77eb3d9
1 changed files with 8 additions and 2 deletions

View File

@ -289,7 +289,8 @@ INT32 BurnStateSave(TCHAR* szName, INT32 bAll)
{
const char szHeader[] = "FB1 "; // File identifier
INT32 nLen = 0, nVer = 0;
INT32 nRet = 0;
INT32 nRet = 0;
TCHAR szBackupName[1024] = _T("");
if (bAll) { // Get amount of data
StateInfo(&nLen, &nVer, 1);
@ -299,7 +300,12 @@ INT32 BurnStateSave(TCHAR* szName, INT32 bAll)
if (nLen <= 0) { // No data, so exit without creating a savestate
return 0; // Don't return an error code
}
#ifdef _WIN32
// backup last savestate just incase - dink
_stprintf(szBackupName, _T("%s.backup"), szName);
DeleteFileW(szBackupName);
MoveFileW(szName, szBackupName);
#endif
FILE* fp = _tfopen(szName, _T("wb"));
if (fp == NULL) {
return 1;