diff --git a/frontend/menu/file_browser.c b/frontend/menu/file_browser.c index c477fa3774..6d58eda017 100644 --- a/frontend/menu/file_browser.c +++ b/frontend/menu/file_browser.c @@ -129,12 +129,6 @@ bool filebrowser_iterate(void *data, unsigned action) case FILEBROWSER_ACTION_RESET: ret = directory_parse(filebrowser, filebrowser->current_dir.root_dir); break; - case FILEBROWSER_ACTION_RESET_CURRENT_DIR: - ret = directory_parse(filebrowser, filebrowser->current_dir.directory_path); - break; - case FILEBROWSER_ACTION_PATH_ISDIR: - ret = filebrowser->list->elems[filebrowser->current_dir.ptr].attr.b; - break; case FILEBROWSER_ACTION_NOOP: default: break; @@ -147,6 +141,18 @@ bool filebrowser_iterate(void *data, unsigned action) return ret; } +bool filebrowser_is_current_entry_dir(void *data) +{ + filebrowser_t *filebrowser = (filebrowser_t*)data; + return filebrowser->list->elems[filebrowser->current_dir.ptr].attr.b; +} + +bool filebrowser_reset_current_dir(void *data) +{ + filebrowser_t *filebrowser = (filebrowser_t*)data; + return directory_parse(filebrowser, filebrowser->current_dir.directory_path); +} + void filebrowser_update(void *data, uint64_t action_ori, const char *extensions) { filebrowser_action_t action = FILEBROWSER_ACTION_NOOP; diff --git a/frontend/menu/file_browser.h b/frontend/menu/file_browser.h index e59f3785b7..f3cf8c9be1 100644 --- a/frontend/menu/file_browser.h +++ b/frontend/menu/file_browser.h @@ -46,8 +46,6 @@ typedef enum FILEBROWSER_ACTION_SCROLL_UP, FILEBROWSER_ACTION_SCROLL_DOWN, FILEBROWSER_ACTION_RESET, - FILEBROWSER_ACTION_RESET_CURRENT_DIR, - FILEBROWSER_ACTION_PATH_ISDIR, FILEBROWSER_ACTION_NOOP } filebrowser_action_t; @@ -55,5 +53,7 @@ void filebrowser_update(void *data, uint64_t input, const char *extensions); void filebrowser_set_root_and_ext(void *data, const char *ext, const char *root_dir); bool filebrowser_iterate(void *data, unsigned action); void filebrowser_free(void *data); +bool filebrowser_is_current_entry_dir(void *data); +bool filebrowser_reset_current_dir(void *data); #endif /* FILEBROWSER_H_ */ diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 1ba35e30c8..345b54ac0e 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -168,7 +168,7 @@ static void menu_stack_pop(unsigned menu_type) if (rgui->browser->prev_dir.directory_path[0] != '\0') { memcpy(&rgui->browser->current_dir, &rgui->browser->prev_dir, sizeof(*(&rgui->browser->current_dir))); - filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_RESET_CURRENT_DIR); + filebrowser_reset_current_dir(rgui->browser); rgui->browser->current_dir.ptr = rgui->browser->prev_dir.ptr; strlcpy(rgui->browser->current_dir.path, rgui->browser->prev_dir.path, sizeof(rgui->browser->current_dir.path)); @@ -244,7 +244,7 @@ static int select_file(void *data, uint64_t action) switch (action) { case RGUI_ACTION_OK: - if (filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_PATH_ISDIR)) + if (filebrowser_is_current_entry_dir(rgui->browser)) { if (!filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_OK)) { @@ -371,7 +371,7 @@ static int select_directory(void *data, uint64_t action) (void)path; bool ret = true; - bool is_dir = filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_PATH_ISDIR); + bool is_dir = filebrowser_is_current_entry_dir(rgui->browser); bool pop_menu_stack = false; switch (action)