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
This commit is contained in:
Aidan MacDonald 2024-03-31 18:44:00 +01:00
parent 856e3d548b
commit e631fc4723

View file

@ -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--;