mapper: remove trailing slashes from music_directory
When the user configures a music_directory with a trailing slash, it may break playlist loading, because MPD expects a double slash. Chop off the trailing slash.
This commit is contained in:
parent
efb04532df
commit
e3d4fa6946
1
NEWS
1
NEWS
|
@ -41,6 +41,7 @@ ver 0.14.2 (2009/??/??)
|
||||||
- jack: allocate ring buffers before connecting
|
- jack: allocate ring buffers before connecting
|
||||||
- jack: clear "shutdown" flag on reconnect
|
- jack: clear "shutdown" flag on reconnect
|
||||||
- jack: reduced sleep time to 1ms
|
- jack: reduced sleep time to 1ms
|
||||||
|
* mapper: remove trailing slashes from music_directory
|
||||||
|
|
||||||
|
|
||||||
ver 0.14.1 (2009/01/17)
|
ver 0.14.1 (2009/01/17)
|
||||||
|
|
16
src/mapper.c
16
src/mapper.c
|
@ -40,13 +40,27 @@ static size_t music_dir_length;
|
||||||
|
|
||||||
static char *playlist_dir;
|
static char *playlist_dir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate a string, chop all trailing slashes.
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
|
strdup_chop_slash(const char *path_fs)
|
||||||
|
{
|
||||||
|
size_t length = strlen(path_fs);
|
||||||
|
|
||||||
|
while (length > 0 && path_fs[length - 1] == G_DIR_SEPARATOR)
|
||||||
|
--length;
|
||||||
|
|
||||||
|
return g_strndup(path_fs, length);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mapper_set_music_dir(const char *path)
|
mapper_set_music_dir(const char *path)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
music_dir = g_strdup(path);
|
music_dir = strdup_chop_slash(path);
|
||||||
music_dir_length = strlen(music_dir);
|
music_dir_length = strlen(music_dir);
|
||||||
|
|
||||||
ret = stat(music_dir, &st);
|
ret = stat(music_dir, &st);
|
||||||
|
|
Loading…
Reference in New Issue