diff menu.c @ 1481:77a401044935 nuklear_ui

Fix directory navigation in ROM file chooser in Nuklear UI
author Michael Pavone <pavone@retrodev.com>
date Sat, 25 Nov 2017 13:57:38 -0800
parents da1dce39e846
children d82af64c94d2
line wrap: on
line diff
--- a/menu.c	Sat Nov 25 11:31:08 2017 -0800
+++ b/menu.c	Sat Nov 25 13:57:38 2017 -0800
@@ -223,42 +223,10 @@
 		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: