aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmdline.c
diff options
context:
space:
mode:
authorAvuton Olrich <avuton@gmail.com>2010-05-20 06:53:07 -0700
committerAvuton Olrich <avuton@gmail.com>2010-05-20 06:56:43 -0700
commit894573657d0acdb7d1b8023045fbe31ce4712466 (patch)
tree130d378da3ad0a37333cf2753b2b3928cc50f0bd /src/cmdline.c
parent9cce1d749a8ad8b3792881f16dbc4b1ddea49d1f (diff)
downloadmpd-894573657d0acdb7d1b8023045fbe31ce4712466.tar.gz
mpd-894573657d0acdb7d1b8023045fbe31ce4712466.tar.xz
mpd-894573657d0acdb7d1b8023045fbe31ce4712466.zip
cmdline: Add default config paths for win32.
Diffstat (limited to 'src/cmdline.c')
-rw-r--r--src/cmdline.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/cmdline.c b/src/cmdline.c
index da1acefd7..747d7c3bb 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -40,8 +40,12 @@
#include <stdio.h>
#include <stdlib.h>
+#ifdef G_OS_WIN32
+#define CONFIG_FILE_LOCATION "\\mpd\\mpd.conf"
+#else /* G_OS_WIN32 */
#define USER_CONFIG_FILE_LOCATION1 ".mpdconf"
#define USER_CONFIG_FILE_LOCATION2 ".mpd/mpd.conf"
+#endif
static GQuark
cmdline_quark(void)
@@ -171,8 +175,37 @@ parse_cmdline(int argc, char **argv, struct options *options,
} else if (argc <= 1) {
/* default configuration file path */
char *path1;
- char *path2;
+#ifdef G_OS_WIN32
+ path1 = g_build_filename(g_get_user_config_dir(),
+ CONFIG_FILE_LOCATION, NULL);
+ if (g_file_test(path1, G_FILE_TEST_IS_REGULAR))
+ ret = config_read_file(path1, error_r);
+ else {
+ int i = 0;
+ char *system_path = NULL;
+ const char * const *system_config_dirs;
+
+ system_config_dirs = g_get_system_config_dirs();
+
+ while(system_config_dirs[i] != NULL) {
+ system_path = g_build_filename(system_config_dirs[i],
+ CONFIG_FILE_LOCATION,
+ NULL);
+ if(g_file_test(system_path,
+ G_FILE_TEST_IS_REGULAR)) {
+ ret = config_read_file(system_path,error_r);
+ g_free(system_path);
+ g_free(&system_config_dirs);
+ break;
+ }
+ ++i;;
+ }
+ g_free(system_path);
+ g_free(&system_config_dirs);
+ }
+#else /* G_OS_WIN32 */
+ char *path2;
path1 = g_build_filename(g_get_home_dir(),
USER_CONFIG_FILE_LOCATION1, NULL);
path2 = g_build_filename(g_get_home_dir(),
@@ -185,8 +218,12 @@ parse_cmdline(int argc, char **argv, struct options *options,
G_FILE_TEST_IS_REGULAR))
ret = config_read_file(SYSTEM_CONFIG_FILE_LOCATION,
error_r);
+#endif
+
g_free(path1);
+#ifndef G_OS_WIN32
g_free(path2);
+#endif
return ret;
} else if (argc == 2) {