Code

conf: helper functions to build config file names
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 4 Jan 2012 19:36:05 +0000 (20:36 +0100)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 4 Jan 2012 19:36:05 +0000 (20:36 +0100)
src/conf.c
src/conf.h

index 5f35d205d5d70369a0918d2f5cd4e349d2af5b1c..4496abe92a5ee03fe91ec0360e1968381777eb4d 100644 (file)
@@ -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;
index b8e4ed232d59bf94fde477f09b0002c2fcf12087..55bc21b3262b28605bced675d489713792c480dc 100644 (file)
@@ -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);