From 2900092e4e06be77108ed6b8a66c7aa673d0b494 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sat, 25 Nov 2017 13:57:38 -0800 Subject: Fix directory navigation in ROM file chooser in Nuklear UI --HG-- branch : nuklear_ui --- menu.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) (limited to 'menu.c') diff --git a/menu.c b/menu.c index 969b44a..b789d23 100644 --- a/menu.c +++ b/menu.c @@ -223,42 +223,10 @@ void * menu_write_w(uint32_t address, void * context, uint16_t value) case 1: { char buf[4096]; copy_string_from_guest(m68k, dst, buf, sizeof(buf)); - if (!strcmp(buf, "..")) { -#ifdef _WIN32 - if (menu->curpath[1] == ':' && !menu->curpath[2]) { - menu->curpath[0] = PATH_SEP[0]; - menu->curpath[1] = 0; - break; - } -#endif - size_t len = strlen(menu->curpath); - while (len > 0) { - --len; - if (is_path_sep(menu->curpath[len])) { - if (!len) { - //special handling for / - menu->curpath[len+1] = 0; - } else { - menu->curpath[len] = 0; - } - break; - } - } - } else { - char *tmp = menu->curpath; -#ifdef _WIN32 - if (menu->curpath[0] == PATH_SEP[0] && !menu->curpath[1]) { - menu->curpath = strdup(buf); - } else -#endif - 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); - } + buf[sizeof(buf)-1] = 0; + char *tmp = menu->curpath; + menu->curpath = path_append(tmp, buf); + free(tmp); break; } case 2: -- cgit v1.2.3