Warn before overwriting another playlist on disk

When saving a playlist to an existing file on disk,
warn user, unless the playlist's file name remains
unchanged.

Change-Id: I10d82667de5fadb5323be4f981bea9263849f07a
This commit is contained in:
Christian Soffke 2023-06-04 00:43:56 +02:00
parent 2747e920ba
commit 422ea20cef
6 changed files with 55 additions and 27 deletions

View file

@ -65,18 +65,10 @@ int save_playlist_screen(struct playlist_info* playlist)
strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp));
}
dot = strrchr(temp, '.');
if (dot) /* remove extension */
*dot = '\0';
if (!kbd_input(temp, sizeof(temp), NULL))
if (catalog_pick_new_playlist_name(temp, sizeof(temp),
playlist ? playlist->filename :
playlist_get_current()->filename))
{
len = strlen(temp);
if(len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
strlcat(temp, "8", sizeof(temp));
else if(len <= 5 || strcasecmp(&temp[len-5], ".m3u8"))
strlcat(temp, ".m3u8", sizeof(temp));
playlist_save(playlist, temp, NULL, 0);
/* reload in case playlist was saved to cwd */