Mercurial > repos > blastem
changeset 1024:5ebf6ddd5a44
Allow navigating to the root directory on Unix-like systems
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 04 May 2016 22:11:48 -0700 |
parents | f1fd9263ccec |
children | 01a91df5b87c |
files | menu.c |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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;