diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index 26f3b34b4f..a1201d6589 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -40,7 +40,6 @@ #include "splash.h" #include "general.h" #include "pathfuncs.h" -#include "dir.h" /* load a screen to save the playlist passed in (or current playlist if NULL is passed) */ int save_playlist_screen(struct playlist_info* playlist) @@ -74,8 +73,7 @@ int save_playlist_screen(struct playlist_info* playlist) if (len <= 1) /* root or dynamic playlist */ create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8", 1 IF_CNFN_NUM_(, NULL)); - else if (temp[len - 1] == PATH_SEPCH /* dir playlists other than root */ - && temp[len] == '\0') + else if (temp[len - 1] == PATH_SEPCH) /* dir playlists other than root */ { temp[len - 1] = '\0'; @@ -89,24 +87,19 @@ int save_playlist_screen(struct playlist_info* playlist) create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8", 1 IF_CNFN_NUM_(, NULL)); } + else if (!playlist) /* current playlist loaded from a playlist file */ + { + if (!file_exists(temp)) + { + splashf(HZ*2, ID2P(LANG_CATALOG_NO_DIRECTORY), temp); + return 0; + } + } if (catalog_pick_new_playlist_name(temp, sizeof(temp), playlist ? playlist->filename : playlist_get_current()->filename)) { - /* Create dir if necessary */ - if ((p = strrchr(temp, PATH_SEPCH)) && p != (char *) temp) - { - *p = '\0'; - - if (!dir_exists(temp) && mkdir(temp) < 0) - { - splashf(HZ, ID2P(LANG_CATALOG_NO_DIRECTORY), temp); - return 0; - } - *p = PATH_SEPCH; - } - playlist_save(playlist, temp); /* reload in case playlist was saved to cwd */ diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 44ab6b8bd9..6998bda95e 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -411,16 +411,33 @@ static int remove_extension(char* path) bool catalog_pick_new_playlist_name(char *pl_name, size_t buf_size, const char* curr_pl_name) { - char bmark_file[MAX_PATH + 7]; + char bmark_file[MAX_PATH + 7], *p; bool do_save = false; while (!do_save && !remove_extension(pl_name) && !kbd_input(pl_name, buf_size - 7, NULL)) { - do_save = true; + if (*pl_name == PATH_SEPCH) /* Require absolute filenames */ + { + p = strrchr(pl_name, PATH_SEPCH); + do_save = *(p + 1); /* Disallow empty filename */ + + /* prevent illegal characters */ + fix_path_part(p, 1, strlen(p + 1)); + + /* Create dir if necessary */ + if (do_save && p != (char *) pl_name) + { + *p = '\0'; + do_save = dir_exists(pl_name) || mkdir(pl_name) == 0; + if (!do_save) + splashf(HZ*2, ID2P(LANG_CATALOG_NO_DIRECTORY), pl_name); + *p = PATH_SEPCH; + } + } apply_playlist_extension(pl_name, buf_size); /* warn before overwriting existing (different) playlist */ - if (!curr_pl_name || strcmp(curr_pl_name, pl_name)) + if (do_save && (!curr_pl_name || strcmp(curr_pl_name, pl_name))) { if (file_exists(pl_name)) do_save = yesno_pop(ID2P(LANG_REALLY_OVERWRITE)); diff --git a/manual/main_menu/main.tex b/manual/main_menu/main.tex index 37cd52332f..f90eb7f70e 100644 --- a/manual/main_menu/main.tex +++ b/manual/main_menu/main.tex @@ -172,7 +172,6 @@ The details of this menu are covered in specified file. Asks for confirmation whether to remove queued tracks from the current playlist, so that bookmarks can be created (see \reference{ref:createbookmark}). -If no path is provided, playlist is saved to the root directory. \item[Create Playlist:] Rockbox will create a playlist with all tracks from the directory that is