1
0
Fork 0
forked from len0rd/rockbox

Suggest numbered filename when saving untitled playlist

+ update misleading comment for catalog_add_to_a_playlist's
m3u8name parameter (the keyboard picker will be shown even
if it's not NULL)

Change-Id: I7576a83fd40cdcdb7a912c90d8c1d9a8f25e277c
This commit is contained in:
Christian Soffke 2023-10-14 18:40:04 +02:00
parent 831faa3b82
commit bdec7ed31b
4 changed files with 18 additions and 16 deletions

View file

@ -39,6 +39,7 @@
#include "playlist_catalog.h" #include "playlist_catalog.h"
#include "splash.h" #include "splash.h"
#include "filetree.h" #include "filetree.h"
#include "general.h"
/* load a screen to save the playlist passed in (or current playlist if NULL is passed) */ /* load a screen to save the playlist passed in (or current playlist if NULL is passed) */
int save_playlist_screen(struct playlist_info* playlist) int save_playlist_screen(struct playlist_info* playlist)
@ -54,29 +55,27 @@ int save_playlist_screen(struct playlist_info* playlist)
char temp[MAX_PATH+1], *p; char temp[MAX_PATH+1], *p;
int len; int len;
catalog_get_directory(directoryonly, sizeof(directoryonly));
playlist_get_name(playlist, temp, sizeof(temp)-1); playlist_get_name(playlist, temp, sizeof(temp)-1);
len = strlen(temp); len = strlen(temp);
if (len <= 1) /* root or dynamic playlist */ if (len <= 1) /* root or dynamic playlist */
{ create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8",
catalog_get_directory(temp, sizeof(temp)); 1 IF_CNFN_NUM_(, NULL));
strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp));
}
else if (!strcmp((temp + len - 1), "/")) /* dir playlists other than root */ else if (!strcmp((temp + len - 1), "/")) /* dir playlists other than root */
{ {
temp[len - 1] = '\0'; temp[len - 1] = '\0';
catalog_get_directory(directoryonly, sizeof(directoryonly));
if ((p = strrchr(temp, '/'))) /* use last path component as playlist name */ if ((p = strrchr(temp, '/'))) /* use last path component as playlist name */
{ {
strlcat(directoryonly, p, sizeof(directoryonly)); strlcat(directoryonly, p, sizeof(directoryonly));
strlcat(directoryonly, ".m3u8", sizeof(directoryonly)); strlcat(directoryonly, ".m3u8", sizeof(directoryonly));
strmemccpy(temp, directoryonly, sizeof(temp));
} }
else else
strlcat(directoryonly, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(directoryonly)); create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8",
1 IF_CNFN_NUM_(, NULL));
strmemccpy(temp, directoryonly, sizeof(temp));
} }
if (catalog_pick_new_playlist_name(temp, sizeof(temp), if (catalog_pick_new_playlist_name(temp, sizeof(temp),

View file

@ -36,7 +36,7 @@
#define PLAYLIST_DISPLAY_COUNT 10 #define PLAYLIST_DISPLAY_COUNT 10
#define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u8" #define PLAYLIST_UNTITLED_PREFIX "Playlist "
#define PLAYLIST_FLAG_MODIFIED (1u << 0) /* playlist was manually modified */ #define PLAYLIST_FLAG_MODIFIED (1u << 0) /* playlist was manually modified */
#define PLAYLIST_FLAG_DIRPLAY (1u << 1) /* enable directory skipping */ #define PLAYLIST_FLAG_DIRPLAY (1u << 1) /* enable directory skipping */

View file

@ -47,6 +47,7 @@
#include "playlist_viewer.h" #include "playlist_viewer.h"
#include "bookmark.h" #include "bookmark.h"
#include "root_menu.h" #include "root_menu.h"
#include "general.h"
/* Use for recursive directory search */ /* Use for recursive directory search */
struct add_track_context { struct add_track_context {
@ -464,14 +465,16 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
name = strrchr(sel, '/'); name = strrchr(sel, '/');
if (name == NULL || ((sel_attr & ATTR_DIRECTORY) != ATTR_DIRECTORY)) if (name == NULL || ((sel_attr & ATTR_DIRECTORY) != ATTR_DIRECTORY))
name = "/"; create_numbered_filename(playlist, playlist, PLAYLIST_UNTITLED_PREFIX,
".m3u8", 1 IF_CNFN_NUM_(, NULL));
else
{
strlcat(playlist, name, sizeof(playlist)); strlcat(playlist, name, sizeof(playlist));
apply_playlist_extension(playlist, sizeof(playlist));
}
} }
else else
strmemccpy(playlist, m3u8name, MAX_PATH); strmemccpy(playlist, m3u8name, sizeof(playlist));
apply_playlist_extension(playlist, sizeof(playlist));
if (!catalog_pick_new_playlist_name(playlist, sizeof(playlist), NULL)) if (!catalog_pick_new_playlist_name(playlist, sizeof(playlist), NULL))
return false; return false;

View file

@ -43,7 +43,7 @@ bool catalog_pick_new_playlist_name(char *pl_name, size_t buf_size,
* sel_attr : the attributes that tell what type of file we're adding * sel_attr : the attributes that tell what type of file we're adding
* new_playlist : whether we want to create a new playlist or add to an * new_playlist : whether we want to create a new playlist or add to an
* existing one. * existing one.
* m3u8name : filename to save the playlist to, NULL to show the keyboard * m3u8name : NULL, or filename to show in keyboard picker (include the extension!)
* add_to_pl_cb : can be NULL, or a function responsible for handling the * add_to_pl_cb : can be NULL, or a function responsible for handling the
* insert operations itself, in case the caller wants full * insert operations itself, in case the caller wants full
* control over how and what files are actually added. * control over how and what files are actually added.