From 445130f9d0666b2ab8f2d1d0b5d516ca5b663d5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 4 Jan 2012 20:36:05 +0100 Subject: [PATCH] conf: helper functions to build config file names --- src/conf.c | 17 ++++++++++++++--- src/conf.h | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) 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); -- 2.30.2