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

This commit is contained in:
spacy51 2009-08-15 17:43:53 +00:00
parent def4cc5b1f
commit 4d4f53425e
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()