aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-01 19:07:38 +0100
committerMax Kellermann <max@duempel.org>2009-01-01 19:07:38 +0100
commit886ed1b225d50e5e6c220e11b5800f45d36a5d37 (patch)
treeefb0c4f5a89aa44ccb543e34fb9220789c291773 /src
parent46aedbae096a2702fa8879f3632eb60c910dc866 (diff)
downloadmpd-886ed1b225d50e5e6c220e11b5800f45d36a5d37.tar.gz
mpd-886ed1b225d50e5e6c220e11b5800f45d36a5d37.tar.xz
mpd-886ed1b225d50e5e6c220e11b5800f45d36a5d37.zip
mapper: fall back to XDG music directory
If no music_directory is configured, fall back to the XDG music directory, determined by g_get_user_special_dir(G_USER_DIRECTORY_MUSIC).
Diffstat (limited to 'src')
-rw-r--r--src/mapper.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mapper.c b/src/mapper.c
index e9364f878..291816e6e 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -43,11 +43,21 @@ static size_t playlist_dir_length;
void mapper_init(void)
{
- ConfigParam *music_dir_param = parseConfigFilePath(CONF_MUSIC_DIR, 1);
+ ConfigParam *music_dir_param = parseConfigFilePath(CONF_MUSIC_DIR, false);
ConfigParam *playlist_dir_param = parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
int ret;
struct stat st;
+ if (music_dir_param != NULL) {
+ music_dir = g_strdup(music_dir_param->value);
+ } else {
+ music_dir = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC));
+ if (music_dir == NULL)
+ /* GLib failed to determine the XDG music
+ directory - abort */
+ g_error("config parameter \"%s\" not found\n", CONF_MUSIC_DIR);
+ }
+
music_dir = g_strdup(music_dir_param->value);
music_dir_length = strlen(music_dir);