From: Brendan Cully Date: Wed, 27 Jul 2005 00:32:18 +0000 (+0000) Subject: Rework mutt_save_confirm to support confirmappend with IMAP mailboxes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=803a0763bc74f14313800e58ab3bd1983beb7225;p=neomutt Rework mutt_save_confirm to support confirmappend with IMAP mailboxes. I hope I got all cases right. --- diff --git a/muttlib.c b/muttlib.c index 3321ba9c5..2a87349c1 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1256,14 +1256,8 @@ int mutt_save_confirm (const char *s, struct stat *st) } #endif - if (stat (s, st) != -1) + if (magic > 0 && !mx_access (s, W_OK)) { - if (magic == -1) - { - mutt_error (_("%s is not a mailbox!"), s); - return 1; - } - if (option (OPTCONFIRMAPPEND)) { snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s); @@ -1273,32 +1267,39 @@ int mutt_save_confirm (const char *s, struct stat *st) ret = -1; } } - else + + if (stat (s, st) != -1) { + if (magic == -1) + { + mutt_error (_("%s is not a mailbox!"), s); + return 1; + } + } + else #ifdef USE_IMAP - if (magic != M_IMAP) + if (magic != M_IMAP) #endif /* execute the block unconditionally if we don't use imap */ - { - st->st_mtime = 0; - st->st_atime = 0; + { + st->st_mtime = 0; + st->st_atime = 0; - if (errno == ENOENT) - { - if (option (OPTCONFIRMCREATE)) - { - snprintf (tmp, sizeof (tmp), _("Create %s?"), s); - if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO) - ret = 1; - else if (rc == -1) - ret = -1; - } - } - else + if (errno == ENOENT) + { + if (option (OPTCONFIRMCREATE)) { - mutt_perror (s); - return 1; + snprintf (tmp, sizeof (tmp), _("Create %s?"), s); + if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO) + ret = 1; + else if (rc == -1) + ret = -1; } } + else + { + mutt_perror (s); + return 1; + } } CLEARLINE (LINES-1);