diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-11-06 18:07:40 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-11-06 18:07:40 -0800 |
commit | 250831f893ed3a35fc6f59203166341058845bb4 (patch) | |
tree | 9eee87dd6a153dabe026f453a736866dbc522b67 | |
parent | 394e3e3458bfcc9ca35489ca885dbb80adb665b6 (diff) |
More efficient handling of going up one directory in menu
-rw-r--r-- | menu.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -111,9 +111,20 @@ void * menu_write_w(uint32_t address, void * context, uint16_t value) break; } } - char *pieces[] = {menu->curpath, "/", buf}; - menu->curpath = alloc_concat_m(3, pieces); - free(pieces[0]); + if (!strcmp(buf, "..")) { + size_t len = strlen(menu->curpath); + while (len > 1) { + --len; + if (menu->curpath[len] == '/') { + menu->curpath[len] = 0; + break; + } + } + } else { + char *pieces[] = {menu->curpath, "/", buf}; + menu->curpath = alloc_concat_m(3, pieces); + free(pieces[0]); + } break; } default: |