playlist_save: add start/end_index parameters
This commit is contained in:
parent
0103219f00
commit
b0ea3f4261
|
@ -809,7 +809,8 @@ handle_load(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
return playlist_load_spl(&g_playlist, client->player_control,
|
return playlist_load_spl(&g_playlist, client->player_control,
|
||||||
argv[1], &error)
|
argv[1], 0, G_MAXUINT,
|
||||||
|
&error)
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,9 @@ spl_save_playlist(const char *name_utf8, const struct playlist *playlist)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
playlist_load_spl(struct playlist *playlist, struct player_control *pc,
|
playlist_load_spl(struct playlist *playlist, struct player_control *pc,
|
||||||
const char *name_utf8, GError **error_r)
|
const char *name_utf8,
|
||||||
|
unsigned start_index, unsigned end_index,
|
||||||
|
GError **error_r)
|
||||||
{
|
{
|
||||||
GPtrArray *list;
|
GPtrArray *list;
|
||||||
|
|
||||||
|
@ -120,7 +122,10 @@ playlist_load_spl(struct playlist *playlist, struct player_control *pc,
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (unsigned i = 0; i < list->len; ++i) {
|
if (list->len < end_index)
|
||||||
|
end_index = list->len;
|
||||||
|
|
||||||
|
for (unsigned i = start_index; i < end_index; ++i) {
|
||||||
const char *temp = g_ptr_array_index(list, i);
|
const char *temp = g_ptr_array_index(list, i);
|
||||||
if ((playlist_append_uri(playlist, pc, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) {
|
if ((playlist_append_uri(playlist, pc, temp, NULL)) != PLAYLIST_RESULT_SUCCESS) {
|
||||||
/* for windows compatibility, convert slashes */
|
/* for windows compatibility, convert slashes */
|
||||||
|
|
|
@ -54,6 +54,8 @@ spl_save_playlist(const char *name_utf8, const struct playlist *playlist);
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
playlist_load_spl(struct playlist *playlist, struct player_control *pc,
|
playlist_load_spl(struct playlist *playlist, struct player_control *pc,
|
||||||
const char *name_utf8, GError **error_r);
|
const char *name_utf8,
|
||||||
|
unsigned start_index, unsigned end_index,
|
||||||
|
GError **error_r);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue