summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-11-06 18:07:40 -0800
committerMichael Pavone <pavone@retrodev.com>2015-11-06 18:07:40 -0800
commit250831f893ed3a35fc6f59203166341058845bb4 (patch)
tree9eee87dd6a153dabe026f453a736866dbc522b67
parent394e3e3458bfcc9ca35489ca885dbb80adb665b6 (diff)
More efficient handling of going up one directory in menu
-rw-r--r--menu.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/menu.c b/menu.c
index 17cf181..d5dd26d 100644
--- a/menu.c
+++ b/menu.c
@@ -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: