From: Rocco Rutte Date: Wed, 5 Sep 2007 07:16:36 +0000 (+0000) Subject: Interpret relative paths in browser relative to shown dir, not working X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfc9743018df9193af492c4c6ede058dfec71589;p=neomutt Interpret relative paths in browser relative to shown dir, not working dir (closes #2471). --- diff --git a/browser.c b/browser.c index 232fe87e1..0d0122169 100644 --- a/browser.c +++ b/browser.c @@ -989,31 +989,41 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num } else #endif - if (stat (buf, &st) == 0) { - if (S_ISDIR (st.st_mode)) + if (*buf != '/') { - destroy_state (&state); - if (examine_directory (menu, &state, buf, prefix) == 0) - strfcpy (LastDir, buf, sizeof (LastDir)); - else + /* in case dir is relative, make it relative to LastDir, + * not current working dir */ + char tmp[_POSIX_PATH_MAX]; + mutt_concat_path (tmp, LastDir, buf, sizeof (tmp)); + strfcpy (buf, tmp, sizeof (buf)); + } + if (stat (buf, &st) == 0) + { + if (S_ISDIR (st.st_mode)) { - mutt_error _("Error scanning directory."); - if (examine_directory (menu, &state, LastDir, prefix) == -1) + destroy_state (&state); + if (examine_directory (menu, &state, buf, prefix) == 0) + strfcpy (LastDir, buf, sizeof (LastDir)); + else { - mutt_menuDestroy (&menu); - goto bail; + mutt_error _("Error scanning directory."); + if (examine_directory (menu, &state, LastDir, prefix) == -1) + { + mutt_menuDestroy (&menu); + goto bail; + } } + menu->current = 0; + menu->top = 0; + init_menu (&state, menu, title, sizeof (title), buffy); } - menu->current = 0; - menu->top = 0; - init_menu (&state, menu, title, sizeof (title), buffy); + else + mutt_error (_("%s is not a directory."), buf); } else - mutt_error (_("%s is not a directory."), buf); + mutt_perror (buf); } - else - mutt_perror (buf); } MAYBE_REDRAW (menu->redraw); break;