From 5471f58fb16d5038789497ab5e2324e88d5fb6ab Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 15 Feb 2025 02:47:14 -0500 Subject: [PATCH] [Bugfix] set_current_file_ex filebrowser wrong file on resume can't have it both ways blocking directories from filename makes shortcut folders browse into the folder but blocks the folder when the file browser loads it causing you to be in the wrong folder upon resume I wanted a way for the user to be able to leave the slash off so ensure shortcut folders have a trailing slash (on load) Change-Id: I9ea173a90a8c12291a159e7d30ee1076e0ca5d3e --- apps/shortcuts.c | 13 +++++++++++++ apps/tree.c | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) 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)