1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fix config save-load.

This commit is contained in:
Sergey Lipskiy 2013-11-19 15:56:29 +07:00
parent 306f02911b
commit c38bd35251
2 changed files with 16 additions and 4 deletions

View File

@ -93,14 +93,24 @@ void Config_LoadConfig()
Config_SetDefault();
// read configuration
const char *filename = ConfigGetSharedDataFilepath("GLideN64.conf");
f = fopen(filename, "r");
const char * pConfigName = "GLideN64.cfg";
const char * pConfigPath = ConfigGetUserConfigPath();
const size_t nPathLen = strlen(pConfigPath);
const size_t configNameLen = nPathLen + strlen(pConfigName) + 2;
char * pConfigFullName = new char[configNameLen];
strcpy(pConfigFullName, pConfigPath);
if (pConfigPath[nPathLen-1] != '/')
strcat(pConfigFullName, "/");
strcat(pConfigFullName, pConfigName);
f = fopen(pConfigFullName, "r");
if (!f) {
fprintf( stderr, "[GLideN64]: (WW) Couldn't open config file '%s' for reading: %s\n", filename, strerror( errno ) );
fprintf( stderr, "[GLideN64]: (WW) Couldn't open config file '%s' for reading: %s\n", pConfigFullName, strerror( errno ) );
fprintf( stderr, "[GLideN64]: Attempting to write new Config \n");
Config_WriteConfig(filename);
Config_WriteConfig(pConfigFullName);
delete[] pConfigFullName;
return;
}
delete[] pConfigFullName;
while (!feof( f )) {
char *val;

View File

@ -144,6 +144,7 @@ EXPORT void CALL ReadScreen (void **dest, long *width, long *height)
#include "m64p_plugin.h"
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
void (*CheckInterrupts)( void );
void (*renderCallback)() = NULL;
@ -153,6 +154,7 @@ extern "C" {
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context, void (*DebugCallback)(void *, int, const char *))
{
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) dlsym(CoreLibHandle, "ConfigGetSharedDataFilepath");
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) dlsym(CoreLibHandle, "ConfigGetUserConfigPath");
return M64ERR_SUCCESS;
}