diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-25 17:07:09 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-25 17:07:09 -0500 |
commit | a56f549a266e14cdc00a98e8dc3e154f5ac6c23e (patch) | |
tree | b513d9bbf656fe1ac054e3201fe10ac94de461ef /ui.c | |
parent | f6d49d377ac136fc29457b3b4501f0488b6412e3 (diff) |
error box; generally better error handling
Diffstat (limited to 'ui.c')
-rw-r--r-- | ui.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -318,7 +318,20 @@ static char *file_selector_update(Ted *ted, FileSelector *fs) { // free previous entries file_selector_clear_entries(fs); // get new entries - char **files = fs_list_directory(cwd); + char **files; + // if the directory we're in gets deleted, go back a directory. + for (u32 i = 0; i < 100; ++i) { + files = fs_list_directory(cwd); + if (files) break; + else if (i == 0) { + if (fs_path_type(cwd) == FS_NON_EXISTENT) + ted_seterr(ted, "%s is not a directory.", cwd); + else + ted_seterr(ted, "Can't list directory %s.", cwd); + } + file_selector_cd(fs, ".."); + } + if (files) { u32 nfiles; for (nfiles = 0; files[nfiles]; ++nfiles); @@ -367,7 +380,6 @@ static char *file_selector_update(Ted *ted, FileSelector *fs) { } free(files); - } else { ted_seterr(ted, "Couldn't list directory '%s'.", cwd); } |