If vba.ini exists in executable's folder, use it. Else create/use one in %appdata% folder.
This commit is contained in:
parent
def4cc5b1f
commit
4d4f53425e
12
src/Util.cpp
12
src/Util.cpp
|
@ -654,3 +654,15 @@ void utilUpdateSystemColorMaps()
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -41,5 +41,6 @@ z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence);
|
||||||
long utilGzMemTell(gzFile file);
|
long utilGzMemTell(gzFile file);
|
||||||
void utilGBAFindSave(const u8 *, const int);
|
void utilGBAFindSave(const u8 *, const int);
|
||||||
void utilUpdateSystemColorMaps();
|
void utilUpdateSystemColorMaps();
|
||||||
|
bool utilFileExists( const char *filename );
|
||||||
|
|
||||||
#endif // UTIL_H
|
#endif // UTIL_H
|
||||||
|
|
|
@ -27,8 +27,17 @@ void regInit(const char *path)
|
||||||
delete regVbaPath;
|
delete regVbaPath;
|
||||||
regVbaPath = NULL;
|
regVbaPath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If vba.ini exists in executable's folder, use it. Else create/use one in %appdata% folder.
|
||||||
regVbaPath = new CString();
|
regVbaPath = new CString();
|
||||||
regVbaPath->Format(MakeInstanceFilename("%s\\vba.ini"), path);
|
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()
|
void regShutdown()
|
||||||
|
|
Loading…
Reference in New Issue