if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP))
#endif
{
- mutt_str_strfcpy(fname, Context->path, sizeof(fname));
+ mutt_str_strfcpy(fname, Context->mailbox->path, sizeof(fname));
mutt_pretty_mailbox(fname, sizeof(fname));
}
fname[0] = '\0';
if (Context)
{
- mutt_str_strfcpy(fname, Context->path, sizeof(fname));
+ mutt_str_strfcpy(fname, Context->mailbox->path, sizeof(fname));
mutt_pretty_mailbox(fname, sizeof(fname));
}
if (actx->idxlen)
char tmppath[PATH_MAX];
/* Setup the right paths */
- FREE(&ctx->mailbox->realpath);
- mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+ mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
/* We will uncompress to /tmp */
mutt_mktemp(tmppath, sizeof(tmppath));
- ctx->path = mutt_str_strdup(tmppath);
+ mutt_str_strfcpy(ctx->mailbox->path, tmppath, sizeof(ctx->mailbox->path));
- FILE *tmpfp = mutt_file_fopen(ctx->path, "w");
+ FILE *tmpfp = mutt_file_fopen(ctx->mailbox->path, "w");
if (!tmpfp)
return -1;
*/
static struct CompressInfo *set_compress_info(struct Context *ctx)
{
- if (!ctx || !ctx->path)
+ if (!ctx || !ctx->mailbox->path)
return NULL;
if (ctx->compress_info)
return ctx->compress_info;
/* Open is compulsory */
- const char *o = find_hook(MUTT_OPEN_HOOK, ctx->path);
+ const char *o = find_hook(MUTT_OPEN_HOOK, ctx->mailbox->path);
if (!o)
return NULL;
- const char *c = find_hook(MUTT_CLOSE_HOOK, ctx->path);
- const char *a = find_hook(MUTT_APPEND_HOOK, ctx->path);
+ const char *c = find_hook(MUTT_CLOSE_HOOK, ctx->mailbox->path);
+ const char *a = find_hook(MUTT_APPEND_HOOK, ctx->mailbox->path);
struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo));
ctx->compress_info = ci;
break;
case 't':
/* Plaintext, temporary file */
- snprintf(buf, buflen, "%s", NONULL(escape_path(ctx->path)));
+ snprintf(buf, buflen, "%s", NONULL(escape_path(ctx->mailbox->path)));
break;
}
return src;
return -1;
/* If there's no close-hook, or the file isn't writable */
- if (!ci->close || (access(ctx->path, W_OK) != 0))
+ if (!ci->close || (access(ctx->mailbox->path, W_OK) != 0))
ctx->readonly = true;
if (setup_paths(ctx) != 0)
unlock_realpath(ctx);
- ctx->magic = mx_path_probe(ctx->path, NULL);
+ ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
if (ctx->magic == MUTT_UNKNOWN)
{
mutt_error(_("Can't identify the contents of the compressed file"));
or_fail:
/* remove the partial uncompressed file */
- remove(ctx->path);
+ remove(ctx->mailbox->path);
free_compress_info(ctx);
return -1;
}
/* To append we need an append-hook or a close-hook */
if (!ci->append && !ci->close)
{
- mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->path);
+ mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->mailbox->path);
goto oa_fail1;
}
mutt_error(_("Compress command failed: %s"), ci->open);
goto oa_fail2;
}
- ctx->magic = mx_path_probe(ctx->path, NULL);
+ ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
}
else
ctx->magic = MboxType;
oa_fail2:
/* remove the partial uncompressed file */
- remove(ctx->path);
+ remove(ctx->mailbox->path);
oa_fail1:
/* Free the compress_info to prevent close from trying to recompress */
free_compress_info(ctx);
if (!ctx->append)
{
/* If the file was removed, remove the compressed folder too */
- if ((access(ctx->path, F_OK) != 0) && !SaveEmpty)
+ if ((access(ctx->mailbox->path, F_OK) != 0) && !SaveEmpty)
{
remove(ctx->mailbox->realpath);
}
else
{
- remove(ctx->path);
+ remove(ctx->mailbox->path);
}
}
else
if (rc == 0)
{
mutt_any_key_to_continue(NULL);
- mutt_error(_("Error. Preserving temporary file: %s"), ctx->path);
+ mutt_error(_("Error. Preserving temporary file: %s"), ctx->mailbox->path);
}
else
- remove(ctx->path);
+ remove(ctx->mailbox->path);
unlock_realpath(ctx);
}
if (ci->append || ci->close)
return true;
- mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->path);
+ mutt_error(_("Cannot append without an append-hook or close-hook : %s"), ctx->mailbox->path);
return false;
}
*/
struct Context
{
- char *path;
FILE *fp;
struct timespec atime;
struct timespec mtime;
}
/* keepalive failure in mutt_enter_fname may kill connection. #3028 */
- if (Context && !Context->path)
+ if (Context && !Context->mailbox->path)
mutt_context_free(&Context);
if (Context)
new_last_folder = mutt_str_strdup(Context->mailbox->realpath);
else
#endif
- new_last_folder = mutt_str_strdup(Context->path);
+ new_last_folder = mutt_str_strdup(Context->mailbox->path);
*oldcount = Context ? Context->msgcount : 0;
int check = mx_mbox_close(&Context, index_hint);
check = mx_mbox_check(Context, &index_hint);
if (check < 0)
{
- if (!Context->path)
+ if (!Context->mailbox->path)
{
/* fatal error occurred */
mutt_context_free(&Context);
}
/* check for a fatal error, or all messages deleted */
- if (!Context->path)
+ if (!Context->mailbox->path)
mutt_context_free(&Context);
/* if we were in the pager, redisplay the message */
cp = _("Open mailbox");
buf[0] = '\0';
- if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
+ if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->mailbox->path)
{
- mutt_str_strfcpy(buf, Context->path, sizeof(buf));
+ mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
mutt_mailbox(buf, sizeof(buf));
if (!buf[0])
{
if (Context && (Context->magic == MUTT_NOTMUCH))
{
- mutt_str_strfcpy(buf, Context->path, sizeof(buf));
+ mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
mutt_mailbox_vfolder(buf, sizeof(buf));
}
mutt_enter_vfolder(cp, buf, sizeof(buf), 1);
#endif
else
{
- if (ChangeFolderNext && Context && Context->path)
+ if (ChangeFolderNext && Context && Context->mailbox->path)
{
- mutt_str_strfcpy(buf, Context->path, sizeof(buf));
+ mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
}
#ifdef USE_NNTP
#include "copy.h"
#include "curs_lib.h"
#include "globals.h"
+#include "mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
goto bail;
}
- tmpctx = mx_mbox_open(ctx->path, MUTT_APPEND);
+ tmpctx = mx_mbox_open(ctx->mailbox->path, MUTT_APPEND);
if (!tmpctx)
{
rc = -1;
#include "curs_lib.h"
#include "format_flags.h"
#include "globals.h"
+#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_parse.h"
#include "mutt_thread.h"
case 'b':
if (ctx)
{
- p = strrchr(ctx->path, '/');
+ p = strrchr(ctx->mailbox->path, '/');
if (p)
mutt_str_strfcpy(buf, p + 1, buflen);
else
- mutt_str_strfcpy(buf, ctx->path, buflen);
+ mutt_str_strfcpy(buf, ctx->mailbox->path, buflen);
}
else
mutt_str_strfcpy(buf, "(null)", buflen);
/* check that the save-to folder is in the same account */
if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0)
{
- mutt_debug(3, "%s not same server as %s\n", dest, ctx->path);
+ mutt_debug(3, "%s not same server as %s\n", dest, ctx->mailbox->path);
return 1;
}
int rc;
const char *condstore;
- if (imap_parse_path(ctx->path, &mx))
+ if (imap_parse_path(ctx->mailbox->path, &mx))
{
- mutt_error(_("%s is an invalid IMAP path"), ctx->path);
+ mutt_error(_("%s is an invalid IMAP mailbox->path"), ctx->mailbox->path);
return -1;
}
idata->mailbox = mutt_str_strdup(buf);
imap_qualify_path(buf, sizeof(buf), &mx, idata->mailbox);
- FREE(&(ctx->path));
- ctx->path = mutt_str_strdup(buf);
- mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+ mutt_str_strfcpy(ctx->mailbox->path, buf, sizeof(ctx->mailbox->path));
+ mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
idata->ctx = ctx;
struct ImapMbox mx;
int rc;
- if (imap_parse_path(ctx->path, &mx))
+ if (imap_parse_path(ctx->mailbox->path, &mx))
return -1;
/* in APPEND mode, we appear to hijack an existing IMAP connection -
mutt_str_strfcpy(mailbox, "INBOX", sizeof(mailbox));
FREE(&mx.mbox);
- rc = imap_access(ctx->path);
+ rc = imap_access(ctx->mailbox->path);
if (rc == 0)
return 0;
"Saving changed messages... [%d/%d]", ctx->msgcount),
i + 1, ctx->msgcount);
if (!appendctx)
- appendctx = mx_mbox_open(ctx->path, MUTT_APPEND | MUTT_QUIET);
+ appendctx = mx_mbox_open(ctx->mailbox->path, MUTT_APPEND | MUTT_QUIET);
if (!appendctx)
mutt_debug(1, "Error opening mailbox in append mode\n");
else
#include "curs_lib.h"
#include "globals.h"
#include "imap/imap.h"
+#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
struct ImapData *idata = ctx->data;
- if (imap_parse_path(ctx->path, &mx))
+ if (imap_parse_path(ctx->mailbox->path, &mx))
return -1;
imap_fix_path(idata, mx.mbox, mailbox, sizeof(mailbox));
/* check that the save-to folder is in the same account */
if (mutt_account_match(&(idata->conn->account), &(mx.account)) == 0)
{
- mutt_debug(3, "%s not same server as %s\n", dest, ctx->path);
+ mutt_debug(3, "%s not same server as %s\n", dest, ctx->mailbox->path);
return 1;
}
#include "curs_lib.h"
#include "globals.h"
#include "imap/imap.h"
+#include "mailbox.h"
#include "message.h"
#include "mutt_account.h"
#include "mx.h"
imap_cachepath(idata, path, mbox, sizeof(mbox));
else
{
- if (!idata->ctx || imap_parse_path(idata->ctx->path, &mx) < 0)
+ if (!idata->ctx || imap_parse_path(idata->ctx->mailbox->path, &mx) < 0)
return NULL;
imap_cachepath(idata, mx.mbox, mbox, sizeof(mbox));
}
/* check to see if the folder is the currently selected folder before polling */
- if (!Context || !Context->path ||
+ if (!Context || !Context->mailbox->path ||
((tmp->magic == MUTT_IMAP ||
#ifdef USE_NNTP
tmp->magic == MUTT_NNTP ||
tmp->magic == MUTT_NOTMUCH ||
#endif
tmp->magic == MUTT_POP) ?
- (mutt_str_strcmp(tmp->path, Context->path) != 0) :
+ (mutt_str_strcmp(tmp->path, Context->mailbox->path) != 0) :
(sb.st_dev != contex_sb->st_dev || sb.st_ino != contex_sb->st_ino)))
{
switch (tmp->magic)
default:; /* do nothing */
}
}
- else if (CheckMboxSize && Context && Context->path)
+ else if (CheckMboxSize && Context && Context->mailbox->path)
tmp->size = (off_t) sb.st_size; /* update the size of current folder */
#ifdef USE_SIDEBAR
#ifdef USE_NNTP
|| Context->magic == MUTT_NNTP
#endif
- || stat(Context->path, &contex_sb) != 0)
+ || stat(Context->mailbox->path, &contex_sb) != 0)
{
contex_sb.st_dev = 0;
contex_sb.st_ino = 0;
if (data && data->mh_umask)
return data->mh_umask;
- if (stat(ctx->path, &st))
+ if (stat(ctx->mailbox->path, &st))
{
- mutt_debug(1, "stat failed on %s\n", ctx->path);
+ mutt_debug(1, "stat failed on %s\n", ctx->mailbox->path);
return 077;
}
omask = umask(mh_umask(dest));
while (true)
{
- snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, dest->path,
+ snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, dest->mailbox->path,
NONULL(ShortHostname), (int) getpid(), mutt_rand64());
fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
if (fd == -1)
return;
}
- snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->path);
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
/* first, copy unknown sequences */
ofp = fopen(sequences, "r");
snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(MhSeqReplied));
snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(MhSeqFlagged));
- snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->path);
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", ctx->mailbox->path);
ofp = fopen(sequences, "r");
if (ofp)
{
if (ctx->magic == MUTT_MAILDIR)
{
- snprintf(buf, sizeof(buf), "%s/%s", ctx->path, "cur");
+ snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "cur");
if (stat(buf, &st) == 0)
mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
- snprintf(buf, sizeof(buf), "%s/%s", ctx->path, "new");
+ snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "new");
}
else
{
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->path);
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
if (stat(buf, &st) == 0)
mutt_get_stat_timespec(&data->mtime_cur, &st, MUTT_STAT_MTIME);
- mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+ mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
}
if (stat(buf, &st) == 0)
if (subdir)
{
- snprintf(buf, sizeof(buf), "%s/%s", ctx->path, subdir);
+ snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, subdir);
is_old = MarkOld ? (mutt_str_strcmp("cur", subdir) == 0) : false;
}
else
- mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+ mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
dirp = opendir(buf);
if (!dirp)
{
if (!ctx || !md || !*md || ctx->magic != MUTT_MH || Sort != SORT_ORDER)
return;
- mutt_debug(4, "maildir: sorting %s into natural order\n", ctx->path);
+ mutt_debug(4, "maildir: sorting %s into natural order\n", ctx->mailbox->path);
*md = maildir_sort(*md, (size_t) -1, md_cmp_path);
}
#endif
#ifdef USE_HCACHE
- header_cache_t *hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
+ header_cache_t *hc = mutt_hcache_open(HeaderCache, ctx->mailbox->path, NULL);
#endif
for (p = *md, count = 0; p; p = p->next, count++)
if (!sort)
{
- mutt_debug(4, "maildir: need to sort %s by inode\n", ctx->path);
+ mutt_debug(4, "maildir: need to sort %s by inode\n", ctx->mailbox->path);
p = maildir_sort(p, (size_t) -1, md_cmp_inode);
if (!last)
*md = p;
last->next = p;
sort = 1;
p = skip_duplicates(p, &last);
- snprintf(fn, sizeof(fn), "%s/%s", ctx->path, p->h->path);
+ snprintf(fn, sizeof(fn), "%s/%s", ctx->mailbox->path, p->h->path);
}
- snprintf(fn, sizeof(fn), "%s/%s", ctx->path, p->h->path);
+ snprintf(fn, sizeof(fn), "%s/%s", ctx->mailbox->path, p->h->path);
#ifdef USE_HCACHE
if (MaildirHeaderCacheVerify)
if (!ctx->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, 0);
}
if (!ctx->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, count);
}
maildir_delayed_parsing(ctx, &md, &progress);
if (ctx->magic == MUTT_MH)
{
- if (mh_read_sequences(&mhs, ctx->path) < 0)
+ if (mh_read_sequences(&mhs, ctx->mailbox->path) < 0)
{
maildir_free_maildir(&md);
return -1;
return 0;
}
- if (mkdir(ctx->path, S_IRWXU))
+ if (mkdir(ctx->mailbox->path, S_IRWXU))
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/cur", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/cur", ctx->mailbox->path);
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- rmdir(ctx->path);
+ rmdir(ctx->mailbox->path);
return -1;
}
- snprintf(tmp, sizeof(tmp), "%s/new", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/new", ctx->mailbox->path);
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- snprintf(tmp, sizeof(tmp), "%s/cur", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/cur", ctx->mailbox->path);
rmdir(tmp);
- rmdir(ctx->path);
+ rmdir(ctx->mailbox->path);
return -1;
}
- snprintf(tmp, sizeof(tmp), "%s/tmp", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/tmp", ctx->mailbox->path);
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- snprintf(tmp, sizeof(tmp), "%s/cur", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/cur", ctx->mailbox->path);
rmdir(tmp);
- snprintf(tmp, sizeof(tmp), "%s/new", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/new", ctx->mailbox->path);
rmdir(tmp);
- rmdir(ctx->path);
+ rmdir(ctx->mailbox->path);
return -1;
}
return 0;
}
- if (mkdir(ctx->path, S_IRWXU))
+ if (mkdir(ctx->mailbox->path, S_IRWXU))
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", ctx->path);
+ snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", ctx->mailbox->path);
const int i = creat(tmp, S_IRWXU);
if (i == -1)
{
mutt_perror(tmp);
- rmdir(ctx->path);
+ rmdir(ctx->mailbox->path);
return -1;
}
close(i);
struct Header *cur = ctx->hdrs[msgno];
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", ctx->path, cur->path);
+ snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, cur->path);
msg->fp = fopen(path, "r");
if (!msg->fp && (errno == ENOENT) && is_maildir)
- msg->fp = maildir_open_find_message(ctx->path, cur->path, NULL);
+ msg->fp = maildir_open_find_message(ctx->mailbox->path, cur->path, NULL);
if (!msg->fp)
{
omask = umask(mh_umask(ctx));
while (true)
{
- snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s", ctx->path, subdir,
+ snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s", ctx->mailbox->path, subdir,
(long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix);
mutt_debug(2, "Trying %s.\n", path);
{
snprintf(path, sizeof(path), "%s/%lld.R%" PRIu64 ".%s%s", subdir,
(long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix);
- snprintf(full, sizeof(full), "%s/%s", ctx->path, path);
+ snprintf(full, sizeof(full), "%s/%s", ctx->mailbox->path, path);
mutt_debug(2, "renaming %s to %s.\n", msg->path, full);
}
else if (errno != EEXIST)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
}
return -1;
}
- dirp = opendir(ctx->path);
+ dirp = opendir(ctx->mailbox->path);
if (!dirp)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
{
hi++;
snprintf(tmp, sizeof(tmp), "%u", hi);
- snprintf(path, sizeof(path), "%s/%s", ctx->path, tmp);
+ snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, tmp);
if (mutt_file_safe_rename(msg->path, path) == 0)
{
if (hdr)
}
else if (errno != EEXIST)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
}
{
char oldpath[PATH_MAX];
char partpath[PATH_MAX];
- snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path);
+ snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->mailbox->path, h->path);
mutt_str_strfcpy(partpath, h->path, sizeof(partpath));
if (ctx->magic == MUTT_MAILDIR)
if (ctx->magic == MUTT_MH && rc == 0)
{
char newpath[PATH_MAX];
- snprintf(newpath, sizeof(newpath), "%s/%s", ctx->path, h->path);
+ snprintf(newpath, sizeof(newpath), "%s/%s", ctx->mailbox->path, h->path);
rc = mutt_file_safe_rename(newpath, oldpath);
if (rc == 0)
mutt_str_replace(&h->path, partpath);
snprintf(partpath, sizeof(partpath), "%s/%s%s",
(h->read || h->old) ? "cur" : "new", newpath, suffix);
- snprintf(fullpath, sizeof(fullpath), "%s/%s", ctx->path, partpath);
- snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->path, h->path);
+ snprintf(fullpath, sizeof(fullpath), "%s/%s", ctx->mailbox->path, partpath);
+ snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->mailbox->path, h->path);
if (mutt_str_strcmp(fullpath, oldpath) == 0)
{
if (h->deleted && (ctx->magic != MUTT_MAILDIR || !MaildirTrash))
{
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", ctx->path, h->path);
+ snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, h->path);
if (ctx->magic == MUTT_MAILDIR || (MhPurge && ctx->magic == MUTT_MH))
{
#ifdef USE_HCACHE
if (*h->path != ',')
{
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/,%s", ctx->path, h->path);
+ snprintf(tmp, sizeof(tmp), "%s/,%s", ctx->mailbox->path, h->path);
unlink(tmp);
rename(path, tmp);
}
if (!CheckNew)
return 0;
- snprintf(buf, sizeof(buf), "%s/new", ctx->path);
+ snprintf(buf, sizeof(buf), "%s/new", ctx->mailbox->path);
if (stat(buf, &st_new) == -1)
return -1;
- snprintf(buf, sizeof(buf), "%s/cur", ctx->path);
+ snprintf(buf, sizeof(buf), "%s/cur", ctx->mailbox->path);
if (stat(buf, &st_cur) == -1)
return -1;
if (!CheckNew)
return 0;
- mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+ mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
if (stat(buf, &st) == -1)
return -1;
/* create .mh_sequences when there isn't one. */
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->path);
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", ctx->mailbox->path);
i = stat(buf, &st_cur);
if ((i == -1) && (errno == ENOENT))
{
maildir_parse_dir(ctx, &last, NULL, &count, NULL);
maildir_delayed_parsing(ctx, &md, NULL);
- if (mh_read_sequences(&mhs, ctx->path) < 0)
+ if (mh_read_sequences(&mhs, ctx->mailbox->path) < 0)
return -1;
mh_update_maildir(md, &mhs);
mhs_free_sequences(&mhs);
#ifdef USE_HCACHE
if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH)
- hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
+ hc = mutt_hcache_open(HeaderCache, ctx->mailbox->path, NULL);
#endif
if (!ctx->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount);
}
struct stat sb;
struct Progress progress;
- if (stat(ctx->path, &sb) == -1)
+ if (stat(ctx->mailbox->path, &sb) == -1)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
mutt_get_stat_timespec(&ctx->atime, &sb, MUTT_STAT_ATIME);
if (!ctx->quiet)
{
char msgbuf[STRING];
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, 0);
}
struct Progress progress;
/* Save information about the folder at the time we opened it. */
- if (stat(ctx->path, &sb) == -1)
+ if (stat(ctx->mailbox->path, &sb) == -1)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
mutt_get_stat_timespec(&ctx->atime, &sb, MUTT_STAT_ATIME);
if (!ctx->readonly)
- ctx->readonly = access(ctx->path, W_OK) ? true : false;
+ ctx->readonly = access(ctx->mailbox->path, W_OK) ? true : false;
if (!ctx->quiet)
{
char msgbuf[STRING];
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, ReadInc, 0);
}
{
int rc;
- ctx->fp = fopen(ctx->path, "r");
+ ctx->fp = fopen(ctx->mailbox->path, "r");
if (!ctx->fp)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
mutt_sig_block();
*/
static int mbox_mbox_open_append(struct Context *ctx, int flags)
{
- ctx->fp = mutt_file_fopen(ctx->path, (flags & MUTT_NEWFOLDER) ? "w" : "a");
+ ctx->fp = mutt_file_fopen(ctx->mailbox->path, (flags & MUTT_NEWFOLDER) ? "w" : "a");
if (!ctx->fp)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
if (mbox_lock_mailbox(ctx, 1, 1) != 0)
{
- mutt_error(_("Couldn't lock %s"), ctx->path);
+ mutt_error(_("Couldn't lock %s"), ctx->mailbox->path);
mutt_file_fclose(&ctx->fp);
return -1;
}
case MUTT_MMDF:
cmp_headers = mutt_header_cmp_strict;
mutt_file_fclose(&ctx->fp);
- ctx->fp = mutt_file_fopen(ctx->path, "r");
+ ctx->fp = mutt_file_fopen(ctx->mailbox->path, "r");
if (!ctx->fp)
rc = -1;
else
bool unlock = false;
bool modified = false;
- if (stat(ctx->path, &st) == 0)
+ if (stat(ctx->mailbox->path, &st) == 0)
{
if ((mutt_stat_timespec_compare(&st, MUTT_STAT_MTIME, &ctx->mtime) == 0) &&
st.st_size == ctx->size)
if (!st)
{
- if (stat(ctx->path, &st2) < 0)
+ if (stat(ctx->mailbox->path, &st2) < 0)
return;
st = &st2;
}
utimebuf.actime = utimebuf.modtime - 1;
}
- utime(ctx->path, &utimebuf);
+ utime(ctx->mailbox->path, &utimebuf);
}
/**
/* need to open the file for writing in such a way that it does not truncate
* the file, so use read-write mode.
*/
- ctx->fp = freopen(ctx->path, "r+", ctx->fp);
+ ctx->fp = freopen(ctx->mailbox->path, "r+", ctx->fp);
if (!ctx->fp)
{
mx_fastclose_mailbox(ctx);
if (!ctx->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount);
}
fp = NULL;
/* Save the state of this folder. */
- if (stat(ctx->path, &statbuf) == -1)
+ if (stat(ctx->mailbox->path, &statbuf) == -1)
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
unlink(tempfile);
goto bail;
}
mbox_reset_atime(ctx, &statbuf);
/* reopen the mailbox in read-only mode */
- ctx->fp = fopen(ctx->path, "r");
+ ctx->fp = fopen(ctx->mailbox->path, "r");
if (!ctx->fp)
{
unlink(tempfile);
if (CheckMboxSize)
{
- tmp = mutt_find_mailbox(ctx->path);
+ tmp = mutt_find_mailbox(ctx->mailbox->path);
if (tmp && !tmp->new)
mutt_update_mailbox(tmp);
}
FREE(&new_offset);
FREE(&old_offset);
- ctx->fp = freopen(ctx->path, "r", ctx->fp);
+ ctx->fp = freopen(ctx->mailbox->path, "r", ctx->fp);
if (!ctx->fp)
{
mutt_error(_("Could not reopen mailbox"));
struct stat sb;
ctx->append = true;
- ctx->magic = mx_path_probe(ctx->path, NULL);
+ ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
if (ctx->magic == MUTT_UNKNOWN)
{
if (flags & (MUTT_APPEND | MUTT_NEWFOLDER))
}
else
{
- mutt_error(_("%s is not a mailbox"), ctx->path);
+ mutt_error(_("%s is not a mailbox"), ctx->mailbox->path);
return -1;
}
}
if (ctx->magic == MUTT_MAILBOX_ERROR)
{
- if (stat(ctx->path, &sb) == -1)
+ if (stat(ctx->mailbox->path, &sb) == -1)
{
if (errno == ENOENT)
{
}
else
{
- mutt_perror(ctx->path);
+ mutt_perror(ctx->mailbox->path);
return -1;
}
}
struct Context *ctx = mutt_mem_calloc(1, sizeof(*ctx));
- ctx->path = mutt_str_strdup(path);
- if (!ctx->path)
- {
- FREE(&ctx);
- return NULL;
- }
- ctx->mailbox = mutt_find_mailbox(ctx->path);
+ ctx->mailbox = mutt_find_mailbox(ctx->mailbox->path);
if (!ctx->mailbox)
{
- ctx->mailbox = mailbox_new(ctx->path);
+ ctx->mailbox = mailbox_new(ctx->mailbox->path);
ctx->mailbox->flags = MB_HIDDEN;
}
- if (!realpath(ctx->path, ctx->mailbox->realpath))
- mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+ mutt_str_strfcpy(ctx->mailbox->path, path, sizeof(ctx->mailbox->path));
+
+ if (!realpath(ctx->mailbox->path, ctx->mailbox->realpath))
+ mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
ctx->msgnotreadyet = -1;
ctx->collapsed = false;
OptForceRefresh = true;
if (!ctx->quiet)
- mutt_message(_("Reading %s..."), ctx->path);
+ mutt_message(_("Reading %s..."), ctx->mailbox->path);
rc = ctx->mx_ops->mbox_open(ctx);
if (!ctx->quiet)
mutt_clear_error();
if (rc == -2)
- mutt_error(_("Reading from %s interrupted..."), ctx->path);
+ mutt_error(_("Reading from %s interrupted..."), ctx->mailbox->path);
}
else
{
return;
/* fix up the times so mailbox won't get confused */
- if (ctx->peekonly && ctx->path && (mutt_timespec_compare(&ctx->mtime, &ctx->atime) > 0))
+ if (ctx->peekonly && ctx->mailbox->path && (mutt_timespec_compare(&ctx->mtime, &ctx->atime) > 0))
{
#ifdef HAVE_UTIMENSAT
ts[0] = ctx->atime;
ts[1] = ctx->mtime;
- utimensat(0, ctx->path, ts, 0);
+ utimensat(0, ctx->mailbox->path, ts, 0);
#else
ut.actime = ctx->atime.tv_sec;
ut.modtime = ctx->mtime.tv_sec;
- utime(ctx->path, &ut);
+ utime(ctx->mailbox->path, &ut);
#endif /* HAVE_UTIMENSAT */
}
/* never announce that a mailbox we've just left has new mail. #3290
* TODO: really belongs in mx_mbox_close, but this is a nice hook point */
if (!ctx->peekonly)
- mutt_mailbox_setnotified(ctx->path);
+ mutt_mailbox_setnotified(ctx->mailbox->path);
if (ctx->mx_ops)
ctx->mx_ops->mbox_close(ctx);
mutt_header_free(&ctx->hdrs[i]);
FREE(&ctx->hdrs);
FREE(&ctx->v2r);
- FREE(&ctx->path);
FREE(&ctx->pattern);
if (ctx->limit_pattern)
mutt_pattern_free(&ctx->limit_pattern);
if (!ctx->quiet)
{
/* L10N: Displayed before/as a mailbox is being synced */
- mutt_message(_("Writing %s..."), ctx->path);
+ mutt_message(_("Writing %s..."), ctx->mailbox->path);
}
int rc = ctx->mx_ops->mbox_sync(ctx, index_hint);
if ((rc != 0) && !ctx->quiet)
{
/* L10N: Displayed if a mailbox sync fails */
- mutt_error(_("Unable to write %s"), ctx->path);
+ mutt_error(_("Unable to write %s"), ctx->mailbox->path);
}
return rc;
return -1;
}
- if (lstat(ctx->path, &stc) == 0 && stc.st_ino == st.st_ino &&
+ if (lstat(ctx->mailbox->path, &stc) == 0 && stc.st_ino == st.st_ino &&
stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
{
return 0; /* we are in the trash folder: simple sync */
if (read_msgs && Move != MUTT_NO)
{
int is_spool;
- char *p = mutt_find_hook(MUTT_MBOX_HOOK, ctx->path);
+ char *p = mutt_find_hook(MUTT_MBOX_HOOK, ctx->mailbox->path);
if (p)
{
is_spool = 1;
else
{
mutt_str_strfcpy(mbox, Mbox, sizeof(mbox));
- is_spool = mutt_is_spool(ctx->path) && !mutt_is_spool(mbox);
+ is_spool = mutt_is_spool(ctx->mailbox->path) && !mutt_is_spool(mbox);
}
if (is_spool && *mbox)
}
/* copy mails to the trash before expunging */
- if (purge && ctx->deleted && (mutt_str_strcmp(ctx->path, Trash) != 0))
+ if (purge && ctx->deleted && (mutt_str_strcmp(ctx->mailbox->path, Trash) != 0))
{
if (trash_append(ctx) != 0)
{
}
if (ctx->msgcount == ctx->deleted && (ctx->magic == MUTT_MMDF || ctx->magic == MUTT_MBOX) &&
- !mutt_is_spool(ctx->path) && !SaveEmpty)
+ !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty)
{
- mutt_file_unlink_empty(ctx->path);
+ mutt_file_unlink_empty(ctx->mailbox->path);
}
#ifdef USE_SIDEBAR
msgcount = ctx->msgcount;
deleted = ctx->deleted;
- if (purge && ctx->deleted && (mutt_str_strcmp(ctx->path, Trash) != 0))
+ if (purge && ctx->deleted && (mutt_str_strcmp(ctx->mailbox->path, Trash) != 0))
{
if (trash_append(ctx) != 0)
return -1;
mutt_sleep(0);
if (ctx->msgcount == ctx->deleted && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) &&
- !mutt_is_spool(ctx->path) && !SaveEmpty)
+ !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty)
{
- unlink(ctx->path);
+ unlink(ctx->mailbox->path);
mx_fastclose_mailbox(ctx);
return 0;
}
#include "context.h"
#include "curs_lib.h"
#include "globals.h"
+#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_logging.h"
#include "mutt_parse.h"
anum_t first, last, count = 0;
struct Url url;
- mutt_str_strfcpy(buf, ctx->path, sizeof(buf));
+ mutt_str_strfcpy(buf, ctx->mailbox->path, sizeof(buf));
if (url_parse(&url, buf) < 0 || !url.host || !url.path ||
!(url.scheme == U_NNTP || url.scheme == U_NNTPS))
{
url_free(&url);
- mutt_error(_("%s is an invalid newsgroup specification"), ctx->path);
+ mutt_error(_("%s is an invalid newsgroup specification"), ctx->mailbox->path);
return -1;
}
if (ctx->data)
return 0;
- ctx->data = new_ctxdata(ctx->path);
+ ctx->data = new_ctxdata(ctx->mailbox->path);
if (!ctx->data)
return -1;
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
{
- if (np->b->desc && (strcmp(np->b->path, ctx->path) == 0))
+ if (np->b->desc && (strcmp(np->b->path, ctx->mailbox->path) == 0))
return np->b->desc;
}
struct NmCtxData *data = get_ctxdata(ctx);
int rc = 0;
struct Progress progress;
- char *uri = ctx->path;
+ char *uri = ctx->mailbox->path;
bool changed = false;
if (!data)
{
/* all is in this function so we don't use data->progress here */
char msgbuf[PATH_MAX + 64];
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->mailbox->path);
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount);
}
else
header_get_fullpath(h, old, sizeof(old));
- ctx->path = hd->folder;
+ mutt_str_strfcpy(ctx->mailbox->path, hd->folder, sizeof(ctx->mailbox->path));
ctx->magic = hd->magic;
#ifdef USE_HCACHE
rc = mh_sync_mailbox_message(ctx, i, NULL);
#else
rc = mh_sync_mailbox_message(ctx, i);
#endif
- ctx->path = uri;
+ mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path));
ctx->magic = MUTT_NOTMUCH;
if (rc)
FREE(&hd->oldpath);
}
- ctx->path = uri;
+ mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path));
ctx->magic = MUTT_NOTMUCH;
if (!is_longrun(data))
check = mx_mbox_check(Context, &index_hint);
if (check < 0)
{
- if (!Context->path)
+ if (!Context->mailbox->path)
{
/* fatal error occurred */
mutt_context_free(&Context);
struct Progress progress;
#ifdef USE_HCACHE
- header_cache_t *hc = pop_hcache_open(pop_data, ctx->path);
+ header_cache_t *hc = pop_hcache_open(pop_data, ctx->mailbox->path);
#endif
time(&pop_data->check_time);
struct PopData *pop_data = NULL;
struct Url url;
- if (pop_parse_path(ctx->path, &acct))
+ if (pop_parse_path(ctx->mailbox->path, &acct))
{
- mutt_error(_("%s is an invalid POP path"), ctx->path);
+ mutt_error(_("%s is an invalid POP mailbox->path"), ctx->mailbox->path);
return -1;
}
if (!conn)
return -1;
- FREE(&ctx->path);
- ctx->path = mutt_str_strdup(buf);
- mutt_str_strfcpy(ctx->mailbox->realpath, ctx->path, sizeof(ctx->mailbox->realpath));
+ mutt_str_strfcpy(ctx->mailbox->path, buf, sizeof(ctx->mailbox->path));
+ mutt_str_strfcpy(ctx->mailbox->realpath, ctx->mailbox->path, sizeof(ctx->mailbox->realpath));
pop_data = mutt_mem_calloc(1, sizeof(struct PopData));
pop_data->conn = conn;
MUTT_PROGRESS_MSG, WriteInc, ctx->deleted);
#ifdef USE_HCACHE
- hc = pop_hcache_open(pop_data, ctx->path);
+ hc = pop_hcache_open(pop_data, ctx->mailbox->path);
#endif
for (i = 0, j = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++)
}
else
#endif
- if (Context && Context->path)
+ if (Context && Context->mailbox->path)
{
- mutt_str_strfcpy(tmp, Context->path, sizeof(tmp));
+ mutt_str_strfcpy(tmp, Context->mailbox->path, sizeof(tmp));
mutt_pretty_mailbox(tmp, sizeof(tmp));
}
else