diff options
author | Michael Pavone <pavone@retrodev.com> | 2020-11-07 18:27:34 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2020-11-07 18:27:34 -0800 |
commit | 73a30109f67c3d168684ab26f10e9f51df676528 (patch) | |
tree | a3d9cfc166cf1420150e8bdc770f8f9b21bfad70 /nuklear_ui | |
parent | 95e1a756fbb6aa07e9957417bc7dd1c117cda812 (diff) |
Prevent user from getting stuck in directories they don't have permission to read in ROM browser
Diffstat (limited to 'nuklear_ui')
-rw-r--r-- | nuklear_ui/blastem_nuklear.c | 9 |
1 files changed, 9 insertions, 0 deletions
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); |