From 73a30109f67c3d168684ab26f10e9f51df676528 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sat, 7 Nov 2020 18:27:34 -0800 Subject: Prevent user from getting stuck in directories they don't have permission to read in ROM browser --- nuklear_ui/blastem_nuklear.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nuklear_ui/blastem_nuklear.c') diff --git a/nuklear_ui/blastem_nuklear.c b/nuklear_ui/blastem_nuklear.c index 3b770f6..6e0db4d 100644 --- a/nuklear_ui/blastem_nuklear.c +++ b/nuklear_ui/blastem_nuklear.c @@ -88,6 +88,15 @@ void view_file_browser(struct nk_context *context, uint8_t normal_open) if (entries) { sort_dir_list(entries, num_entries); } + if (!num_entries) { + //get_dir_list can fail if the user doesn't have permission + //for the current folder, make sure they can still navigate up + free_dir_list(entries, num_entries); + entries = calloc(1, sizeof(dir_entry)); + entries[0].name = strdup(".."); + entries[0].is_dir = 1; + num_entries = 1; + } } if (!got_ext_list) { ext_list = get_extension_list(config, &num_exts); -- cgit v1.2.3