aboutsummaryrefslogtreecommitdiff
path: root/src/stored_playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-25 13:43:57 +0100
committerMax Kellermann <max@duempel.org>2009-01-25 13:43:57 +0100
commit2c45224be72e06463ddd48956ecaef61da9dfecb (patch)
tree6753a329a3654c23cd681a6df2d1847050a481ea /src/stored_playlist.c
parent7cc15ffc08dae8d46460ad4b47657fef12bd534b (diff)
mapper: added dot to PLAYLIST_FILE_SUFFIX
Some code will be a little bit simpler if the dot is part of the string literal.
Diffstat (limited to 'src/stored_playlist.c')
-rw-r--r--src/stored_playlist.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/stored_playlist.c b/src/stored_playlist.c
index 94170283..26dcb34d 100644
--- a/src/stored_playlist.c
+++ b/src/stored_playlist.c
@@ -42,14 +42,11 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
struct stat st;
struct stored_playlist_info *playlist;
- if (name_length < 1 + sizeof(PLAYLIST_FILE_SUFFIX) ||
+ if (name_length < sizeof(PLAYLIST_FILE_SUFFIX) ||
memchr(name_fs, '\n', name_length) != NULL)
return NULL;
- if (name_fs[name_length - sizeof(PLAYLIST_FILE_SUFFIX)] != '.' ||
- memcmp(name_fs + name_length - sizeof(PLAYLIST_FILE_SUFFIX) + 1,
- PLAYLIST_FILE_SUFFIX,
- sizeof(PLAYLIST_FILE_SUFFIX) - 1) != 0)
+ if (!g_str_has_suffix(name_fs, PLAYLIST_FILE_SUFFIX))
return NULL;
path_fs = g_build_filename(parent_path_fs, name_fs, NULL);
@@ -58,8 +55,8 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
if (ret < 0 || !S_ISREG(st.st_mode))
return NULL;
- name = g_strdup(name_fs);
- name[name_length - sizeof(PLAYLIST_FILE_SUFFIX)] = 0;
+ name = g_strndup(name_fs,
+ name_length + 1 - sizeof(PLAYLIST_FILE_SUFFIX));
name_utf8 = fs_charset_to_utf8(name);
g_free(name);
if (name_utf8 == NULL)