aboutsummaryrefslogtreecommitdiffstats
path: root/src/mapper.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-31 16:47:14 +0100
committerMax Kellermann <max@duempel.org>2008-10-31 16:47:14 +0100
commitd8e877e3355d0858c78a6d9a7060a6683024dd30 (patch)
treecdc996fa583c1f996da6ff18500b7cf360e182e1 /src/mapper.c
parentef542716196b90b71480ee952db64c3df736a12e (diff)
downloadmpd-d8e877e3355d0858c78a6d9a7060a6683024dd30.tar.gz
mpd-d8e877e3355d0858c78a6d9a7060a6683024dd30.tar.xz
mpd-d8e877e3355d0858c78a6d9a7060a6683024dd30.zip
path: moved playlist_dir to mapper.c
Added the function map_spl_utf8_to_fs() which replaces utf8_to_fs_playlist_path().
Diffstat (limited to '')
-rw-r--r--src/mapper.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mapper.c b/src/mapper.c
index f0a546eb2..a21b42d92 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -34,9 +34,13 @@
static char *music_dir;
static size_t music_dir_length;
+static char *playlist_dir;
+static size_t playlist_dir_length;
+
void mapper_init(void)
{
ConfigParam *music_dir_param = parseConfigFilePath(CONF_MUSIC_DIR, 1);
+ ConfigParam *playlist_dir_param = parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
int ret;
struct stat st;
@@ -51,11 +55,24 @@ void mapper_init(void)
else if (!S_ISDIR(st.st_mode))
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);
}
void mapper_finish(void)
{
g_free(music_dir);
+ g_free(playlist_dir);
}
static char *
@@ -117,3 +134,24 @@ map_fs_to_utf8(const char *path_fs, char *buffer)
return fs_charset_to_utf8(buffer, path_fs);
}
+
+static char *rpp2app_r(char *dst, const char *rel_path)
+{
+ pfx_dir(dst, rel_path, strlen(rel_path),
+ playlist_dir, playlist_dir_length);
+ return dst;
+}
+
+const char *
+map_spl_path(void)
+{
+ return playlist_dir;
+}
+
+const char *
+map_spl_utf8_to_fs(const char *name, char *buffer)
+{
+ rpp2app_r(buffer, utf8_to_fs_charset(buffer, name));
+ g_strlcat(buffer, "." PLAYLIST_FILE_SUFFIX, MPD_PATH_MAX);
+ return buffer;
+}