aboutsummaryrefslogtreecommitdiffstats
path: root/src/mapper.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-18 16:15:45 +0100
committerMax Kellermann <max@duempel.org>2009-01-18 16:15:45 +0100
commit9933144de7389b12b2a75cfb4320baecefa952af (patch)
tree09d7fc155aa64e596c38a2a7d7908e6c8705bf3b /src/mapper.c
parentc2cc3b4923684cb00518e7b8db25a9b56c60dc9d (diff)
downloadmpd-9933144de7389b12b2a75cfb4320baecefa952af.tar.gz
mpd-9933144de7389b12b2a75cfb4320baecefa952af.tar.xz
mpd-9933144de7389b12b2a75cfb4320baecefa952af.zip
mapper: make the playlist directory optional
Diffstat (limited to 'src/mapper.c')
-rw-r--r--src/mapper.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/mapper.c b/src/mapper.c
index 028d35b22..2c3e50ab0 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -39,14 +39,29 @@ static char *music_dir;
static size_t music_dir_length;
static char *playlist_dir;
-static size_t playlist_dir_length;
+
+static void
+mapper_set_playlist_dir(const char *path, int line)
+{
+ int ret;
+ struct stat st;
+
+ playlist_dir = g_strdup(path);
+
+ ret = stat(playlist_dir, &st);
+ if (ret < 0)
+ g_warning("failed to stat playlist directory \"%s\" (config line %i): %s\n",
+ playlist_dir, line, g_strerror(errno));
+ else if (!S_ISDIR(st.st_mode))
+ g_warning("playlist directory is not a directory: \"%s\" (config line %i)\n",
+ playlist_dir, line);
+}
void mapper_init(void)
{
struct config_param *music_dir_param =
parseConfigFilePath(CONF_MUSIC_DIR, false);
- struct config_param *playlist_dir_param =
- parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
+ struct config_param *param;
int ret;
struct stat st;
@@ -73,17 +88,9 @@ void mapper_init(void)
g_warning("music directory is not a directory: \"%s\" (config line %i)\n",
music_dir_param->value, music_dir_param->line);
- playlist_dir = g_strdup(playlist_dir_param->value);
- playlist_dir_length = strlen(playlist_dir);
-
- ret = stat(playlist_dir, &st);
- if (ret < 0)
- g_warning("failed to stat playlist directory \"%s\" (config line %i): %s\n",
- playlist_dir_param->value, playlist_dir_param->line,
- strerror(errno));
- else if (!S_ISDIR(st.st_mode))
- g_warning("playlist directory is not a directory: \"%s\" (config line %i)\n",
- playlist_dir_param->value, playlist_dir_param->line);
+ param = parseConfigFilePath(CONF_PLAYLIST_DIR, false);
+ if (param != NULL)
+ mapper_set_playlist_dir(param->value, param->line);
}
void mapper_finish(void)
@@ -183,6 +190,9 @@ map_spl_utf8_to_fs(const char *name)
char *filename = g_strconcat(name, "." PLAYLIST_FILE_SUFFIX, NULL);
char *path;
+ if (playlist_dir == NULL)
+ return NULL;
+
path = g_build_filename(playlist_dir, filename, NULL);
g_free(filename);