# HG changeset patch # User Michael Pavone # Date 1462425108 25200 # Node ID 5ebf6ddd5a446db697551121504005dc9532a501 # Parent f1fd9263ccec8ece7afad2c3c43608b60684215a Allow navigating to the root directory on Unix-like systems diff -r f1fd9263ccec -r 5ebf6ddd5a44 menu.c --- a/menu.c Wed May 04 00:56:33 2016 -0700 +++ b/menu.c Wed May 04 22:11:48 2016 -0700 @@ -193,17 +193,26 @@ 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;