From d9ccd3974eb4d277ef5e784ea65448560696bbb4 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Wed, 13 Sep 2000 09:47:54 +0000 Subject: [PATCH] Let the browser handle non-existent directories more gracefully. From Byrial Jensen. --- browser.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/browser.c b/browser.c index c30bea45d..1bdb7cee2 100644 --- a/browser.c +++ b/browser.c @@ -34,6 +34,7 @@ #include #include #include +#include static struct mapping_t FolderHelp[] = { { N_("Exit"), OP_EXIT }, @@ -343,7 +344,7 @@ static void init_state (struct browser_state *state, MUTTMENU *menu) } static int examine_directory (MUTTMENU *menu, struct browser_state *state, - const char *d, const char *prefix) + char *d, const char *prefix) { struct stat s; DIR *dp; @@ -351,8 +352,19 @@ static int examine_directory (MUTTMENU *menu, struct browser_state *state, char buffer[_POSIX_PATH_MAX + SHORT_STRING]; BUFFY *tmp; - if (stat (d, &s) == -1) + while (stat (d, &s) == -1) { + if (errno == ENOENT) + { + /* The last used directory is deleted, try to use the parent dir. */ + char *c = strrchr (d, '/'); + + if (c && (c > d)) + { + *c = 0; + continue; + } + } mutt_perror (d); return (-1); } -- 2.40.0