- added missing recursive directory creation after user prompt
- checked for trailing '/' when saving mbox
else
strfcpy(LastSaveFolder, buf, sizeof(LastSaveFolder));
+ /* check if path is a filename by comparing last character
+ * (mboxes need filenames, not directories)
+ */
+ if (DefaultMagic == MUTT_MBOX && buf[strlen(buf) - 1] == '/')
+ {
+ mutt_error(_("'%s' is a directory, need a filename for mbox."), buf);
+ return -1;
+ }
+
mutt_expand_path(buf, sizeof(buf));
/* check to make sure that this file is really the one the user wants */
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
+#include <libgen.h>
#include <libintl.h>
#include <limits.h>
#include <pwd.h>
st->st_mtime = 0;
st->st_atime = 0;
+ /* pathname does not exist */
if (errno == ENOENT)
{
if (option(OPTCONFIRMCREATE))
else if (rc == MUTT_ABORT)
ret = -1;
}
+
+ /* user confirmed with MUTT_YES or set OPTCONFIRMCREATE */
+ if (ret == 0)
+ {
+ strncpy(tmp, s, sizeof(tmp) - 1);
+
+ /* create dir recursively */
+ if (mutt_mkdir(dirname(tmp), S_IRWXU) == -1)
+ {
+ /* report failure & abort */
+ mutt_perror(s);
+ return 1;
+ }
+ }
}
else
{