1
0
Fork 0
forked from Miroirs/x49gp

use Glib to get user config dir

This commit is contained in:
Gwenhael Le Moine 2024-11-13 14:35:40 +01:00
parent 7b574b609f
commit 6f1041c369
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -245,11 +245,9 @@ void config_init( char* progname, int argc, char* argv[] )
}
}
char config_dir[ strlen( progname ) + 9 ];
const char* home = g_get_home_dir();
sprintf( config_dir, ".config/%s", progname );
const char* user_config_dir = g_get_user_config_dir();
opt.config_lua_filename = g_build_filename( home, config_dir, config_lua_filename, NULL );
opt.config_lua_filename = g_build_filename( user_config_dir, progname, config_lua_filename, NULL );
/**********************/
/* 1. read config.lua */
@ -318,7 +316,7 @@ void config_init( char* progname, int argc, char* argv[] )
if ( !haz_config_file ) {
fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", opt.config_lua_filename );
fprintf( stderr, "You can solve this by running `mkdir -p %s/%s && %s --print-config >> %s`\n\n", home, config_dir, progname,
fprintf( stderr, "You can solve this by running `mkdir -p %s/%s && %s --print-config >> %s`\n\n", user_config_dir, progname, progname,
opt.config_lua_filename );
}
@ -341,5 +339,5 @@ void config_init( char* progname, int argc, char* argv[] )
}
if ( opt.state_filename == NULL )
opt.state_filename = g_build_filename( home, config_dir, "state", NULL );
opt.state_filename = g_build_filename( user_config_dir, progname, "state", NULL );
}