path: moved playlist_dir to mapper.c

Added the function map_spl_utf8_to_fs() which replaces
utf8_to_fs_playlist_path().
This commit is contained in:
Max Kellermann
2008-10-31 16:47:14 +01:00
parent ef54271619
commit d8e877e335
7 changed files with 81 additions and 58 deletions

View File

@@ -32,8 +32,6 @@
#include <glib.h>
static const char *playlistDir;
static size_t playlist_dir_len;
static char *fsCharset;
char *fs_charset_to_utf8(char *dst, const char *str)
@@ -99,22 +97,10 @@ const char *getFsCharset(void)
void initPaths(void)
{
ConfigParam *playlistParam = parseConfigFilePath(CONF_PLAYLIST_DIR, 1);
ConfigParam *fsCharsetParam = getConfigParam(CONF_FS_CHARSET);
char *charset = NULL;
char *originalLocale;
DIR *dir;
playlistDir = xstrdup(playlistParam->value);
playlist_dir_len = strlen(playlistDir);
if ((dir = opendir(playlistDir)) == NULL) {
ERROR("cannot open %s \"%s\" (config line %i): %s\n",
CONF_PLAYLIST_DIR, playlistParam->value,
playlistParam->line, strerror(errno));
} else
closedir(dir);
if (fsCharsetParam) {
charset = xstrdup(fsCharsetParam->value);
@@ -183,13 +169,6 @@ char *pfx_dir(char *dst,
return (dst + pfx_len + 1);
}
char *rpp2app_r(char *dst, const char *rel_path)
{
pfx_dir(dst, rel_path, strlen(rel_path),
(const char *)playlistDir, playlist_dir_len);
return dst;
}
char *sanitizePathDup(const char *path)
{
int len = strlen(path) + 1;
@@ -229,10 +208,3 @@ char *sanitizePathDup(const char *path)
return xrealloc(ret, len + 1);
}
void utf8_to_fs_playlist_path(char *path_max_tmp, const char *utf8path)
{
utf8_to_fs_charset(path_max_tmp, utf8path);
rpp2app_r(path_max_tmp, path_max_tmp);
strncat(path_max_tmp, "." PLAYLIST_FILE_SUFFIX, MPD_PATH_MAX - 1);
}