From: Jonathan Neuschäfer Date: Wed, 4 Jan 2012 19:36:05 +0000 (+0100) Subject: conf: helper functions to build config file names X-Git-Tag: release-0.20~7 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=445130f9d0666b2ab8f2d1d0b5d516ca5b663d5e;p=ncmpc.git conf: helper functions to build config file names --- diff --git a/src/conf.c b/src/conf.c index 5f35d20..4496abe 100644 --- a/src/conf.c +++ b/src/conf.c @@ -601,6 +601,18 @@ check_user_conf_dir(void) return retval; } +char * +build_user_conf_filename(void) +{ + return g_build_filename(g_get_home_dir(), "." PACKAGE, "config", NULL); +} + +char * +build_system_conf_filename(void) +{ + return g_build_filename(SYSCONFDIR, PACKAGE, "config", NULL); +} + char * build_user_key_binding_filename(void) { @@ -618,8 +630,7 @@ read_configuration(void) /* check for user configuration ~/.ncmpc/config */ if (filename == NULL) { - filename = g_build_filename(g_get_home_dir(), - "." PACKAGE, "config", NULL); + filename = build_user_conf_filename(); if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(filename); filename = NULL; @@ -628,7 +639,7 @@ read_configuration(void) /* check for global configuration SYSCONFDIR/ncmpc/config */ if (filename == NULL) { - filename = g_build_filename(SYSCONFDIR, PACKAGE, "config", NULL); + filename = build_system_conf_filename(); if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(filename); filename = NULL; diff --git a/src/conf.h b/src/conf.h index b8e4ed2..55bc21b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -21,6 +21,9 @@ int check_user_conf_dir(void); +char *build_user_conf_filename(void); +char *build_system_conf_filename(void); + char *build_user_key_binding_filename(void); int read_configuration(void);