summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-05-04 22:11:48 -0700
committerMichael Pavone <pavone@retrodev.com>2016-05-04 22:11:48 -0700
commit7abda487de0fdbad67f1d1f56bca04f7ce7a6a55 (patch)
tree34af42dc7502c343ee13ba665b5dd78e9e9a1e6d /menu.c
parent7dda453ce9f3ad3bd97f06d476d07d096ef50de8 (diff)
Allow navigating to the root directory on Unix-like systems
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/menu.c b/menu.c
index 6d8786e..30a42e2 100644
--- a/menu.c
+++ b/menu.c
@@ -193,17 +193,26 @@ void * menu_write_w(uint32_t address, void * context, uint16_t value)
copy_string_from_guest(m68k, dst, buf, sizeof(buf));
if (!strcmp(buf, "..")) {
size_t len = strlen(menu->curpath);
- while (len > 1) {
+ while (len > 0) {
--len;
if (is_path_sep(menu->curpath[len])) {
- menu->curpath[len] = 0;
+ if (!len) {
+ //special handling for /
+ menu->curpath[len+1] = 0;
+ } else {
+ menu->curpath[len] = 0;
+ }
break;
}
}
} else {
char *tmp = menu->curpath;
- char const *pieces[] = {menu->curpath, PATH_SEP, buf};
- menu->curpath = alloc_concat_m(3, pieces);
+ if (is_path_sep(menu->curpath[strlen(menu->curpath) - 1])) {
+ menu->curpath = alloc_concat(menu->curpath, buf);
+ } else {
+ char const *pieces[] = {menu->curpath, PATH_SEP, buf};
+ menu->curpath = alloc_concat_m(3, pieces);
+ }
free(tmp);
}
break;