command: added print_spl_list()
The function print_spl_list() replaces the old function lsPlaylists() from ls.c.
This commit is contained in:
parent
a65e20b50e
commit
f8e586402d
@ -202,6 +202,17 @@ static int print_playlist_result(struct client *client,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_spl_list(struct client *client, GPtrArray *list)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < list->len; ++i) {
|
||||||
|
struct stored_playlist_info *playlist =
|
||||||
|
g_ptr_array_index(list, i);
|
||||||
|
|
||||||
|
client_printf(client, "playlist: %s\n", playlist->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int handleUrlHandlers(struct client *client,
|
static int handleUrlHandlers(struct client *client,
|
||||||
mpd_unused int argc, mpd_unused char *argv[])
|
mpd_unused int argc, mpd_unused char *argv[])
|
||||||
{
|
{
|
||||||
@ -524,8 +535,13 @@ static int handleLsInfo(struct client *client,
|
|||||||
|
|
||||||
directory_print(client, directory);
|
directory_print(client, directory);
|
||||||
|
|
||||||
if (isRootDirectory(path))
|
if (isRootDirectory(path)) {
|
||||||
return lsPlaylists(client, path);
|
GPtrArray *list = spl_list();
|
||||||
|
if (list != NULL) {
|
||||||
|
print_spl_list(client, list);
|
||||||
|
spl_list_free(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
18
src/ls.c
18
src/ls.c
@ -98,24 +98,6 @@ int isRemoteUrl(const char *url)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsPlaylists(struct client *client, const char *utf8path)
|
|
||||||
{
|
|
||||||
GPtrArray *list = spl_list();
|
|
||||||
if (list == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < list->len; ++i) {
|
|
||||||
struct stored_playlist_info *playlist =
|
|
||||||
g_ptr_array_index(list, i);
|
|
||||||
|
|
||||||
client_printf(client, "playlist: %s%s\n",
|
|
||||||
utf8path, playlist->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
spl_list_free(list);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* suffixes should be ascii only characters */
|
/* suffixes should be ascii only characters */
|
||||||
const char *getSuffix(const char *utf8file)
|
const char *getSuffix(const char *utf8file)
|
||||||
{
|
{
|
||||||
|
2
src/ls.h
2
src/ls.h
@ -26,8 +26,6 @@
|
|||||||
struct stat;
|
struct stat;
|
||||||
struct client;
|
struct client;
|
||||||
|
|
||||||
int lsPlaylists(struct client *client, const char *utf8path);
|
|
||||||
|
|
||||||
const char *getSuffix(const char *utf8file);
|
const char *getSuffix(const char *utf8file);
|
||||||
|
|
||||||
int isValidRemoteUtf8Url(const char *utf8url);
|
int isValidRemoteUtf8Url(const char *utf8url);
|
||||||
|
Loading…
Reference in New Issue
Block a user