From e631fc4723adc3a5f151a87d8429399aa34d5217 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sun, 31 Mar 2024 18:44:00 +0100 Subject: tree: handle trailing slashes in currdir when navigating up Make ft_exit() ignore trailing slashes. Previously if these ended up in "currdir" then pressing the back button would just leave you in the same directory. Change-Id: Ic539e02a9860fa13ca3235beaf99bb474c66e151 --- apps/filetree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/filetree.c b/apps/filetree.c index 66b5c843ca..11d562f586 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -820,6 +820,11 @@ int ft_exit(struct tree_context* c) int rc = 0; bool exit_func = false; int i = strlen(c->currdir); + + /* strip trailing slashes */ + while (c->currdir[i-1] == PATH_SEPCH) + i--; + if (i>1) { while (c->currdir[i-1]!=PATH_SEPCH) i--; -- cgit v1.2.3