If vba.ini exists in executable's folder, use it. Else create/use one in %appdata% folder.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@885 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2009-08-15 17:43:53 +00:00
parent b388acba36
commit 0eccbe84bd
3 changed files with 22 additions and 0 deletions

View File

@ -654,3 +654,15 @@ void utilUpdateSystemColorMaps()
break;
}
}
// Check for existence of file.
bool utilFileExists( const char *filename )
{
FILE *f = fopen( filename, "r" );
if( f == NULL ) {
return false;
} else {
fclose( f );
return true;
}
}

View File

@ -41,5 +41,6 @@ z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence);
long utilGzMemTell(gzFile file);
void utilGBAFindSave(const u8 *, const int);
void utilUpdateSystemColorMaps();
bool utilFileExists( const char *filename );
#endif // UTIL_H

View File

@ -27,8 +27,17 @@ void regInit(const char *path)
delete regVbaPath;
regVbaPath = NULL;
}
// If vba.ini exists in executable's folder, use it. Else create/use one in %appdata% folder.
regVbaPath = new CString();
regVbaPath->Format(MakeInstanceFilename("%s\\vba.ini"), path);
if( !utilFileExists( regVbaPath->GetString() ) ) {
TCHAR appdata[MAX_PATH+1];
SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appdata );
regVbaPath->Format( "%s\\VBA-M", appdata );
SHCreateDirectoryEx( NULL, regVbaPath->GetString(), NULL );
regVbaPath->Append( "\\vba.ini" );
}
}
void regShutdown()