Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
1480:8464a3f09b94 | 1481:77a401044935 |
---|---|
221 break; | 221 break; |
222 } | 222 } |
223 case 1: { | 223 case 1: { |
224 char buf[4096]; | 224 char buf[4096]; |
225 copy_string_from_guest(m68k, dst, buf, sizeof(buf)); | 225 copy_string_from_guest(m68k, dst, buf, sizeof(buf)); |
226 if (!strcmp(buf, "..")) { | 226 buf[sizeof(buf)-1] = 0; |
227 #ifdef _WIN32 | 227 char *tmp = menu->curpath; |
228 if (menu->curpath[1] == ':' && !menu->curpath[2]) { | 228 menu->curpath = path_append(tmp, buf); |
229 menu->curpath[0] = PATH_SEP[0]; | 229 free(tmp); |
230 menu->curpath[1] = 0; | |
231 break; | |
232 } | |
233 #endif | |
234 size_t len = strlen(menu->curpath); | |
235 while (len > 0) { | |
236 --len; | |
237 if (is_path_sep(menu->curpath[len])) { | |
238 if (!len) { | |
239 //special handling for / | |
240 menu->curpath[len+1] = 0; | |
241 } else { | |
242 menu->curpath[len] = 0; | |
243 } | |
244 break; | |
245 } | |
246 } | |
247 } else { | |
248 char *tmp = menu->curpath; | |
249 #ifdef _WIN32 | |
250 if (menu->curpath[0] == PATH_SEP[0] && !menu->curpath[1]) { | |
251 menu->curpath = strdup(buf); | |
252 } else | |
253 #endif | |
254 if (is_path_sep(menu->curpath[strlen(menu->curpath) - 1])) { | |
255 menu->curpath = alloc_concat(menu->curpath, buf); | |
256 } else { | |
257 char const *pieces[] = {menu->curpath, PATH_SEP, buf}; | |
258 menu->curpath = alloc_concat_m(3, pieces); | |
259 } | |
260 free(tmp); | |
261 } | |
262 break; | 230 break; |
263 } | 231 } |
264 case 2: | 232 case 2: |
265 case 8: { | 233 case 8: { |
266 char buf[4096]; | 234 char buf[4096]; |