diff --git a/apps/shortcuts.c b/apps/shortcuts.c index cdff6c69ad..0ac3fbea9c 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c @@ -369,11 +369,24 @@ static int readline_cb(int n, char *buf, void *parameters) *param = NULL; break; case SHORTCUT_BROWSER: + { + char *p = strmemccpy(sc->u.path, value, MAX_PATH); + if (p && dir_exists(value)) + { + /* ensure ending slash */ + *p = '\0'; + if (*(p-2) != '/') + *(p-1) = '/'; + } + break; + } case SHORTCUT_FILE: case SHORTCUT_DEBUGITEM: case SHORTCUT_PLAYLISTMENU: + { strmemccpy(sc->u.path, value, MAX_PATH); break; + } case SHORTCUT_SETTING_APPLY: case SHORTCUT_SETTING: /* can handle 'name: value' pair for either type */ diff --git a/apps/tree.c b/apps/tree.c index 0ea9b74d19..8b9348f7b9 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -634,7 +634,7 @@ static void set_current_file_ex(const char *path, const char *filename) return; #endif - if (!filename && !dir_exists(path)) /* path and filename supplied combined */ + if (!filename) /* path and filename supplied combined */ { /* separate directory from filename */ /* gets the directory's name and put it into tc.currdir */ @@ -653,8 +653,6 @@ static void set_current_file_ex(const char *path, const char *filename) } else /* path and filename came in separate ensure an ending '/' */ { - if (!filename) - filename = ""; char *end_p = strmemccpy(tc.currdir, path, MAX_PATH); size_t endpos = end_p - tc.currdir; if (endpos < MAX_PATH)