Index: apps/playlist.c =================================================================== --- apps/playlist.c (revision 17158) +++ apps/playlist.c (working copy) @@ -3613,3 +3613,12 @@ return result; } + +/* + * Check if a folder exists, if not try to create it + * return 0 if it exists, <0 otherwise + */ +int check_mkdir(const char* dirname) +{ + return !dir_exists(dirname) ? mkdir(dirname):0; +} Index: apps/playlist_catalog.c =================================================================== --- apps/playlist_catalog.c (revision 17158) +++ apps/playlist_catalog.c (working copy) @@ -75,33 +75,21 @@ /* fall back to default directory if no or invalid config */ if (default_dir) - strncpy(playlist_dir, PLAYLIST_CATALOG_DEFAULT_DIR, - sizeof(playlist_dir)); + strncpy(playlist_dir, DEFAULT_PLAYLIST_DIR, sizeof(playlist_dir)); playlist_dir_length = strlen(playlist_dir); - - if (dir_exists(playlist_dir)) + if(check_mkdir(playlist_dir)==0) { playlist_dir_exists = true; memset(most_recent_playlist, 0, sizeof(most_recent_playlist)); initialized = true; } - } - - if (!playlist_dir_exists) - { - if (mkdir(playlist_dir) < 0) { - gui_syncsplash(HZ*2, str(LANG_CATALOG_NO_DIRECTORY), - playlist_dir); + else + { + gui_syncsplash(HZ*2, str(LANG_CATALOG_NO_DIRECTORY), playlist_dir); return -1; } - else { - playlist_dir_exists = true; - memset(most_recent_playlist, 0, sizeof(most_recent_playlist)); - initialized = true; - } } - return 0; } /* Use the filetree functions to retrieve the list of playlists in the Index: apps/tree.c =================================================================== --- apps/tree.c (revision 17158) +++ apps/tree.c (working copy) @@ -989,7 +989,9 @@ pltick = current_tick; snprintf(filename, sizeof filename, "%s.m3u8", - tc.currdir[1] ? tc.currdir : "/root"); + tc.currdir[1] ? tc.currdir : + check_mkdir(DEFAULT_PLAYLIST_DIR)==0 ? + DEFAULT_PLAYLIST_DIR"/root" : "/root"); FOR_NB_SCREENS(i) { gui_textarea_clear(&screens[i]); Index: apps/playlist.h =================================================================== --- apps/playlist.h (revision 17158) +++ apps/playlist.h (working copy) @@ -30,6 +30,7 @@ #define PLAYLIST_ATTR_SKIPPED 0x04 #define PLAYLIST_MAX_CACHE 16 +#define DEFAULT_PLAYLIST_DIR "/Playlists" #define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u8" enum playlist_command { @@ -127,6 +128,7 @@ int playlist_update_resume_info(const struct mp3entry* id3); int playlist_get_display_index(void); int playlist_amount(void); +int check_mkdir(const char*); /* Exported functions for all playlists. Pass NULL for playlist_info structure to work with current playlist. */ Index: apps/menus/playlist_menu.c =================================================================== --- apps/menus/playlist_menu.c (revision 17158) +++ apps/menus/playlist_menu.c (working copy) @@ -50,7 +50,12 @@ strcat(temp, "8"); if (len <= 5 || strcasecmp(&temp[len-5], ".m3u8")) - strcpy(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME); + { + strcpy(temp, + check_mkdir(DEFAULT_PLAYLIST_DIR)==0 ? + DEFAULT_PLAYLIST_DIR DEFAULT_DYNAMIC_PLAYLIST_NAME : + DEFAULT_DYNAMIC_PLAYLIST_NAME); + } if (!kbd_input(temp, sizeof(temp))) {