Win32 - Function for checking if backupsavestate exists

This commit is contained in:
adelikat 2008-12-20 01:04:15 +00:00
parent fe5d1b2313
commit 7b035bb3bc
3 changed files with 39 additions and 1 deletions

View File

@ -1,5 +1,14 @@
#include "common.h" #include "common.h"
#include <string>
#include <string.h>
#include <fstream>
using namespace std;
//Externs
extern int CurrentState; //Declared in src/state.cpp
bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists
/** /**
* Show an Save File dialog and save a savegame state to the selected file. * Show an Save File dialog and save a savegame state to the selected file.
**/ **/
@ -56,3 +65,30 @@ void FCEUD_LoadStateFrom()
FCEUI_LoadState(nameo); FCEUI_LoadState(nameo);
} }
} }
bool CheckBackupSaveStateExist()
{
//This function simply checks to see if the backup savestate of the appropriate filename exists
string filename;
int x;
filename = strdup(FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0).c_str()); //Generate normal savestate filename
x = filename.find_last_of("."); //Find last dot
filename = filename.substr(0,x); //Chop off file extension
filename.append(".bak"); //add .bak
//Check if this filename exists
fstream test;
test.open(filename.c_str(),fstream::in);
if (test.fail())
{
test.close();
return false;
}
else
{
test.close();
return true;
}
}

View File

@ -92,6 +92,7 @@ void SetAutoFireOffset(int offset);
void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add
void MapInput(void); void MapInput(void);
extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog
extern bool CheckBackupSaveStateExist(); //Checks if backupsavestate exists
//AutoFire----------------------------------------------- //AutoFire-----------------------------------------------
static int CheckedAutoFirePattern = MENU_AUTOFIRE_PATTERN_1; static int CheckedAutoFirePattern = MENU_AUTOFIRE_PATTERN_1;

View File

@ -849,5 +849,6 @@ void BackupSaveState()
x = filename.find_last_of("."); //Find last dot x = filename.find_last_of("."); //Find last dot
filename = filename.substr(0,x); //Chop off file extension filename = filename.substr(0,x); //Chop off file extension
filename.append(".bak"); //add .bak filename.append(".bak"); //add .bak
FCEUI_printf("%s\n",filename.c_str());
} }