From f8d991fc1b1ab7ae0c3d8a0307b8b2419d152278 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 21 Mar 2017 00:40:25 -0700 Subject: Allow initial_path to contain variable references which allows the default value to be actually specified in the default config file --- menu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'menu.c') diff --git a/menu.c b/menu.c index 44c33ee..277697e 100644 --- a/menu.c +++ b/menu.c @@ -167,15 +167,16 @@ void * menu_write_w(uint32_t address, void * context, uint16_t value) if (!menu) { gen->extra = menu = calloc(1, sizeof(menu_context)); menu->curpath = tern_find_path(config, "ui\0initial_path\0").ptrval; - if (menu->curpath) { - menu->curpath = strdup(menu->curpath); - } else { + if (!menu->curpath){ #ifdef __ANDROID__ - menu->curpath = strdup(get_external_storage_path()); + menu->curpath = get_external_storage_path(); #else - menu->curpath = strdup(get_home_dir()); + menu->curpath = "$HOME"; #endif } + tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir()); + vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir()); + menu->curpath = replace_vars(menu->curpath, vars, 1); } if (menu->state) { uint32_t dst = menu->latch << 16 | value; -- cgit v1.2.3