diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index 5a12e6b2..a41fa24e 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -3,6 +3,7 @@ #include "MainWnd.h" #include +#include #include "FileDlg.h" #include "Reg.h" @@ -48,6 +49,12 @@ MainWnd::~MainWnd() { } +bool MainWnd::fileExists( LPCTSTR lpFileName ) +{ + // check if file exists + return GetFileAttributes( lpFileName ) != INVALID_FILE_ATTRIBUTES; +} + BEGIN_MESSAGE_MAP(MainWnd, CWnd) //{{AFX_MSG_MAP(MainWnd) @@ -1154,9 +1161,7 @@ void MainWnd::screenCapture(int captureNumber) captureNumber, ext); - // check if file exists - DWORD dwAttr = GetFileAttributes( buffer ); - if( dwAttr != INVALID_FILE_ATTRIBUTES ) { + if( fileExists( buffer ) ) { // screenshot file already exists screenCapture(++captureNumber); // this will recursively use the first non-existent screenshot number diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index 48b39998..b1fa8d8d 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -30,6 +30,9 @@ public: void winSaveCheatList(const char *name); void winSaveCheatListDefault(); +private: + bool fileExists( LPCTSTR lpFileName ); + DECLARE_MESSAGE_MAP()