mapper: added dot to PLAYLIST_FILE_SUFFIX
Some code will be a little bit simpler if the dot is part of the string literal.
This commit is contained in:
parent
7cc15ffc08
commit
2c45224be7
@ -203,7 +203,7 @@ map_spl_path(void)
|
|||||||
char *
|
char *
|
||||||
map_spl_utf8_to_fs(const char *name)
|
map_spl_utf8_to_fs(const char *name)
|
||||||
{
|
{
|
||||||
char *filename = g_strconcat(name, "." PLAYLIST_FILE_SUFFIX, NULL);
|
char *filename = g_strconcat(name, PLAYLIST_FILE_SUFFIX, NULL);
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
if (playlist_dir == NULL)
|
if (playlist_dir == NULL)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define PLAYLIST_FILE_SUFFIX "m3u"
|
#define PLAYLIST_FILE_SUFFIX ".m3u"
|
||||||
|
|
||||||
struct directory;
|
struct directory;
|
||||||
struct song;
|
struct song;
|
||||||
|
@ -42,14 +42,11 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
struct stored_playlist_info *playlist;
|
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)
|
memchr(name_fs, '\n', name_length) != NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (name_fs[name_length - sizeof(PLAYLIST_FILE_SUFFIX)] != '.' ||
|
if (!g_str_has_suffix(name_fs, PLAYLIST_FILE_SUFFIX))
|
||||||
memcmp(name_fs + name_length - sizeof(PLAYLIST_FILE_SUFFIX) + 1,
|
|
||||||
PLAYLIST_FILE_SUFFIX,
|
|
||||||
sizeof(PLAYLIST_FILE_SUFFIX) - 1) != 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_fs = g_build_filename(parent_path_fs, name_fs, 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))
|
if (ret < 0 || !S_ISREG(st.st_mode))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
name = g_strdup(name_fs);
|
name = g_strndup(name_fs,
|
||||||
name[name_length - sizeof(PLAYLIST_FILE_SUFFIX)] = 0;
|
name_length + 1 - sizeof(PLAYLIST_FILE_SUFFIX));
|
||||||
name_utf8 = fs_charset_to_utf8(name);
|
name_utf8 = fs_charset_to_utf8(name);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
if (name_utf8 == NULL)
|
if (name_utf8 == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user