struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &ml, entries)
{
- if (mutt_str_strcmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) != 0)
+ if (mutt_str_strcmp(mutt_b2s(buf), mailbox_path(np->mailbox)) != 0)
break;
}
np->mailbox->msg_unread = Context->mailbox->msg_unread;
}
- mutt_buffer_strcpy(mailbox, mutt_b2s(np->mailbox->pathbuf));
+ mutt_buffer_strcpy(mailbox, mailbox_path(np->mailbox));
if (C_BrowserAbbreviateMailboxes)
mutt_buffer_pretty_mailbox(mailbox);
continue;
case MUTT_NOTMUCH:
case MUTT_NNTP:
- add_folder(menu, state, mutt_b2s(np->mailbox->pathbuf),
+ add_folder(menu, state, mailbox_path(np->mailbox),
np->mailbox->name, NULL, np->mailbox, NULL);
continue;
default: /* Continue */
break;
}
- if (lstat(mutt_b2s(np->mailbox->pathbuf), &s) == -1)
+ if (lstat(mailbox_path(np->mailbox), &s) == -1)
continue;
if ((!S_ISREG(s.st_mode)) && (!S_ISDIR(s.st_mode)) && (!S_ISLNK(s.st_mode)))
{
struct stat st2;
- mutt_buffer_printf(md, "%s/new", mutt_b2s(np->mailbox->pathbuf));
+ mutt_buffer_printf(md, "%s/new", mailbox_path(np->mailbox));
if (stat(mutt_b2s(md), &s) < 0)
s.st_mtime = 0;
- mutt_buffer_printf(md, "%s/cur", mutt_b2s(np->mailbox->pathbuf));
+ mutt_buffer_printf(md, "%s/cur", mailbox_path(np->mailbox));
if (stat(mutt_b2s(md), &st2) < 0)
st2.st_mtime = 0;
if (st2.st_mtime > s.st_mtime)
// TODO(sileht): It could be better to select INBOX instead. But I
// don't want to manipulate Context/Mailboxes/mailbox->account here for now.
// Let's just protect neomutt against crash for now. #1417
- if (mutt_str_strcmp(mutt_b2s(Context->mailbox->pathbuf),
+ if (mutt_str_strcmp(mailbox_path(Context->mailbox),
state.entry[nentry].name) == 0)
{
mutt_error(_("Can't delete currently selected mailbox"));
if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->mailbox->magic == MUTT_NNTP))
#endif
{
- mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf));
+ mutt_str_strfcpy(buf, mailbox_path(Context->mailbox), sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
}
buf[0] = '\0';
if (Context)
{
- mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf));
+ mutt_str_strfcpy(buf, mailbox_path(Context->mailbox), sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
}
if (actx->idxlen)
char tmp[PATH_MAX];
/* Setup the right paths */
- mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf));
+ mutt_str_replace(&m->realpath, mailbox_path(m));
/* We will uncompress to /tmp */
mutt_mktemp(tmp, sizeof(tmp));
mutt_buffer_strcpy(m->pathbuf, tmp);
- FILE *fp = mutt_file_fopen(mutt_b2s(m->pathbuf), "w");
+ FILE *fp = mutt_file_fopen(mailbox_path(m), "w");
if (!fp)
return -1;
return m->compress_info;
/* Open is compulsory */
- const char *o = find_hook(MUTT_OPEN_HOOK, mutt_b2s(m->pathbuf));
+ const char *o = find_hook(MUTT_OPEN_HOOK, mailbox_path(m));
if (!o)
return NULL;
- const char *c = find_hook(MUTT_CLOSE_HOOK, mutt_b2s(m->pathbuf));
- const char *a = find_hook(MUTT_APPEND_HOOK, mutt_b2s(m->pathbuf));
+ const char *c = find_hook(MUTT_CLOSE_HOOK, mailbox_path(m));
+ const char *a = find_hook(MUTT_APPEND_HOOK, mailbox_path(m));
struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo));
m->compress_info = ci;
break;
case 't':
/* Plaintext, temporary file */
- mutt_buffer_quote_filename(quoted, mutt_b2s(m->pathbuf), false);
+ mutt_buffer_quote_filename(quoted, mailbox_path(m), false);
snprintf(buf, buflen, "%s", mutt_b2s(quoted));
break;
}
return true;
mutt_error(_("Can't append without an append-hook or close-hook : %s"),
- mutt_b2s(m->pathbuf));
+ mailbox_path(m));
return false;
}
int rc;
/* If there's no close-hook, or the file isn't writable */
- if (!ci->cmd_close || (access(mutt_b2s(m->pathbuf), W_OK) != 0))
+ if (!ci->cmd_close || (access(mailbox_path(m), W_OK) != 0))
m->readonly = true;
if (setup_paths(m) != 0)
unlock_realpath(m);
- m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL);
+ m->magic = mx_path_probe(mailbox_path(m), NULL);
if (m->magic == MUTT_UNKNOWN)
{
mutt_error(_("Can't identify the contents of the compressed file"));
cmo_fail:
/* remove the partial uncompressed file */
- remove(mutt_b2s(m->pathbuf));
+ remove(mailbox_path(m));
free_compress_info(m);
return -1;
}
if (!ci->cmd_append && !ci->cmd_close)
{
mutt_error(_("Can't append without an append-hook or close-hook : %s"),
- mutt_b2s(m->pathbuf));
+ mailbox_path(m));
goto cmoa_fail1;
}
mutt_error(_("Compress command failed: %s"), ci->cmd_open);
goto cmoa_fail2;
}
- m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL);
+ m->magic = mx_path_probe(mailbox_path(m), NULL);
}
else
m->magic = C_MboxType;
cmoa_fail2:
/* remove the partial uncompressed file */
- remove(mutt_b2s(m->pathbuf));
+ remove(mailbox_path(m));
cmoa_fail1:
/* Free the compress_info to prevent close from trying to recompress */
free_compress_info(m);
if (rc == 0)
{
mutt_any_key_to_continue(NULL);
- mutt_error(_("Error. Preserving temporary file: %s"), mutt_b2s(m->pathbuf));
+ mutt_error(_("Error. Preserving temporary file: %s"), mailbox_path(m));
}
else
- remove(mutt_b2s(m->pathbuf));
+ remove(mailbox_path(m));
unlock_realpath(m);
}
else
{
/* If the file was removed, remove the compressed folder too */
- if ((access(mutt_b2s(m->pathbuf), F_OK) != 0) && !C_SaveEmpty)
+ if ((access(mailbox_path(m), F_OK) != 0) && !C_SaveEmpty)
{
remove(m->realpath);
}
else
{
- remove(mutt_b2s(m->pathbuf));
+ remove(mailbox_path(m));
}
}
struct Mailbox *m = NULL;
STAILQ_FOREACH(np, &ml, entries)
{
- if ((stat(mutt_b2s(np->mailbox->pathbuf), &tmp_sb) == 0) &&
+ if ((stat(mailbox_path(np->mailbox), &tmp_sb) == 0) &&
(sb.st_dev == tmp_sb.st_dev) && (sb.st_ino == tmp_sb.st_ino))
{
m = np->mailbox;
if (!m)
return;
- if (stat(mutt_b2s(m->pathbuf), &sb) == 0)
+ if (stat(mailbox_path(m), &sb) == 0)
m->size = (off_t) sb.st_size;
else
m->size = 0;
void mailbox_size_sub (struct Mailbox *m, const struct Email *e);
void mailbox_update (struct Mailbox *m);
+static inline const char *mailbox_path(const struct Mailbox *m)
+{
+ return mutt_b2s(m->pathbuf);
+}
+
#endif /* MUTT_CORE_MAILBOX_H */
case 'b':
if (m)
{
- p = strrchr(mutt_b2s(m->pathbuf), '/');
+ p = strrchr(mailbox_path(m), '/');
if (p)
mutt_str_strfcpy(buf, p + 1, buflen);
else
- mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), buflen);
+ mutt_str_strfcpy(buf, mailbox_path(m), buflen);
}
else
mutt_str_strfcpy(buf, "(null)", buflen);
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &ml, entries)
{
- if (mutt_str_strcmp(tmp, mutt_b2s(np->mailbox->pathbuf)) == 0)
+ if (mutt_str_strcmp(tmp, mailbox_path(np->mailbox)) == 0)
break;
}
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &ml, entries)
{
- if (!mutt_str_startswith(mutt_b2s(np->mailbox->pathbuf), buf, CASE_MATCH))
+ if (!mutt_str_startswith(mailbox_path(np->mailbox), buf, CASE_MATCH))
continue;
if (rc)
{
- mutt_str_strfcpy(buf, mutt_b2s(np->mailbox->pathbuf), buflen);
+ mutt_str_strfcpy(buf, mailbox_path(np->mailbox), buflen);
rc = 0;
}
else
- longest_common_prefix(buf, mutt_b2s(np->mailbox->pathbuf), matchlen, buflen);
+ longest_common_prefix(buf, mailbox_path(np->mailbox), matchlen, buflen);
}
neomutt_mailboxlist_clear(&ml);
/* check that the save-to folder is in the same account */
if (!mutt_account_match(&(adata->conn->account), &(dest_adata->conn->account)))
{
- mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mutt_b2s(m->pathbuf));
+ mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mailbox_path(m));
goto out;
}
struct ConnAccount conn_account;
char mailbox[PATH_MAX];
- if (imap_parse_path(mutt_b2s(m->pathbuf), &conn_account, mailbox, sizeof(mailbox)) < 0)
+ if (imap_parse_path(mailbox_path(m), &conn_account, mailbox, sizeof(mailbox)) < 0)
return -1;
adata = imap_adata_new();
if (!m->mdata)
{
- struct Url *url = url_parse(mutt_b2s(m->pathbuf));
+ struct Url *url = url_parse(mailbox_path(m));
struct ImapMboxData *mdata = imap_mdata_new(adata, url->path);
/* fixup path and realpath, mainly to replace / by /INBOX */
char buf[1024];
imap_qualify_path(buf, sizeof(buf), &adata->conn_account, mdata->name);
mutt_buffer_strcpy(m->pathbuf, buf);
- mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf));
+ mutt_str_replace(&m->realpath, mailbox_path(m));
m->mdata = mdata;
m->free_mdata = imap_mdata_free;
/* check that the save-to folder is in the same account */
if (!mutt_account_match(&adata->conn->account, &conn_account))
{
- mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mutt_b2s(m->pathbuf));
+ mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mailbox_path(m));
return 1;
}
m = mailbox_find_name(buf);
if (m)
{
- mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), buflen);
+ mutt_str_strfcpy(buf, mailbox_path(m), buflen);
}
else
{
new_last_folder = mutt_str_strdup(Context->mailbox->realpath);
else
#endif
- new_last_folder = mutt_str_strdup(mutt_b2s(Context->mailbox->pathbuf));
+ new_last_folder = mutt_str_strdup(mailbox_path(Context->mailbox));
*oldcount = Context->mailbox->msg_count;
int check = mx_mbox_close(&Context);
if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context &&
Context->mailbox && !mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
- mutt_buffer_strcpy(folderbuf, mutt_b2s(Context->mailbox->pathbuf));
+ mutt_buffer_strcpy(folderbuf, mailbox_path(Context->mailbox));
mutt_buffer_pretty_mailbox(folderbuf);
mutt_mailbox_next_buffer(Context ? Context->mailbox : NULL, folderbuf);
if (mutt_buffer_is_empty(folderbuf))
m = mutt_sb_get_highlight();
if (!m)
goto changefoldercleanup;
- mutt_buffer_strcpy(folderbuf, mutt_b2s(m->pathbuf));
+ mutt_buffer_strcpy(folderbuf, mailbox_path(m));
/* Mark the selected dir for the neomutt browser */
- mutt_browser_select_dir(mutt_b2s(m->pathbuf));
+ mutt_browser_select_dir(mailbox_path(m));
}
#endif
else
if (C_ChangeFolderNext && Context && Context->mailbox &&
mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
- mutt_buffer_strcpy(folderbuf, mutt_b2s(Context->mailbox->pathbuf));
+ mutt_buffer_strcpy(folderbuf, mailbox_path(Context->mailbox));
mutt_buffer_pretty_mailbox(folderbuf);
}
#ifdef USE_NNTP
if (!clear_this && tmp_valid)
{
clear_this =
- (mutt_str_strcasecmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) == 0) ||
+ (mutt_str_strcasecmp(mutt_b2s(buf), mailbox_path(np->mailbox)) == 0) ||
(mutt_str_strcasecmp(mutt_b2s(buf), np->mailbox->name) == 0);
}
struct MailboxList ml = neomutt_mailboxlist_get_all(NeoMutt, MUTT_NOTMUCH);
struct MailboxNode *mp = STAILQ_FIRST(&ml);
if (mp)
- cs_str_string_set(Config, "spoolfile", mutt_b2s(mp->mailbox->pathbuf), NULL);
+ cs_str_string_set(Config, "spoolfile", mailbox_path(mp->mailbox), NULL);
neomutt_mailboxlist_clear(&ml);
}
#endif
struct Buffer *path = mutt_buffer_pool_get();
struct Buffer *msgpath = mutt_buffer_pool_get();
- mutt_buffer_printf(path, "%s/%s", mutt_b2s(m->pathbuf), dir_name);
+ mutt_buffer_printf(path, "%s/%s", mailbox_path(m), dir_name);
/* when $mail_check_recent is set, if the new/ directory hasn't been modified since
* the user last exited the m, then we know there is no recent mail. */
mutt_buffer_printf(partpath, "%s/%s%s", (e->read || e->old) ? "cur" : "new",
mutt_b2s(newpath), suffix);
- mutt_buffer_printf(fullpath, "%s/%s", mutt_b2s(m->pathbuf), mutt_b2s(partpath));
- mutt_buffer_printf(oldpath, "%s/%s", mutt_b2s(m->pathbuf), e->path);
+ mutt_buffer_printf(fullpath, "%s/%s", mailbox_path(m), mutt_b2s(partpath));
+ mutt_buffer_printf(oldpath, "%s/%s", mailbox_path(m), e->path);
if (mutt_str_strcmp(mutt_b2s(fullpath), mutt_b2s(oldpath)) == 0)
{
return 0;
}
- if (mkdir(mutt_b2s(m->pathbuf), S_IRWXU))
+ if (mkdir(mailbox_path(m), S_IRWXU))
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/cur", mailbox_path(m));
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- rmdir(mutt_b2s(m->pathbuf));
+ rmdir(mailbox_path(m));
return -1;
}
- snprintf(tmp, sizeof(tmp), "%s/new", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/new", mailbox_path(m));
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/cur", mailbox_path(m));
rmdir(tmp);
- rmdir(mutt_b2s(m->pathbuf));
+ rmdir(mailbox_path(m));
return -1;
}
- snprintf(tmp, sizeof(tmp), "%s/tmp", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/tmp", mailbox_path(m));
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/cur", mailbox_path(m));
rmdir(tmp);
- snprintf(tmp, sizeof(tmp), "%s/new", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/new", mailbox_path(m));
rmdir(tmp);
- rmdir(mutt_b2s(m->pathbuf));
+ rmdir(mailbox_path(m));
return -1;
}
return 0;
struct Buffer *buf = mutt_buffer_pool_get();
- mutt_buffer_printf(buf, "%s/new", mutt_b2s(m->pathbuf));
+ mutt_buffer_printf(buf, "%s/new", mailbox_path(m));
if (stat(mutt_b2s(buf), &st_new) == -1)
{
mutt_buffer_pool_release(&buf);
return -1;
}
- mutt_buffer_printf(buf, "%s/cur", mutt_b2s(m->pathbuf));
+ mutt_buffer_printf(buf, "%s/cur", mailbox_path(m));
if (stat(mutt_b2s(buf), &st_cur) == -1)
{
mutt_buffer_pool_release(&buf);
while (true)
{
snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s",
- mutt_b2s(m->pathbuf), subdir, (long long) time(NULL),
+ mailbox_path(m), subdir, (long long) time(NULL),
mutt_rand64(), NONULL(ShortHostname), suffix);
mutt_debug(LL_DEBUG2, "Trying %s\n", path);
{
int rc = 0;
#ifdef USE_HCACHE
- header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
+ header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL);
char *key = e->path + 3;
int keylen = maildir_hcache_keylen(key);
rc = mutt_hcache_store(hc, key, keylen, e, 0);
return;
}
- snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox_path(m));
/* first, copy unknown sequences */
FILE *fp_old = fopen(sequences, "r");
char path[PATH_MAX];
struct stat sb;
- if ((snprintf(path, sizeof(path), "%s/.mh_sequences", mutt_b2s(m->pathbuf)) < sizeof(path)) &&
+ if ((snprintf(path, sizeof(path), "%s/.mh_sequences", mailbox_path(m)) < sizeof(path)) &&
(stat(path, &sb) == 0))
{
return (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->last_visited) > 0);
char path[PATH_MAX];
struct stat sb;
- if ((snprintf(path, sizeof(path), "%s/%d", mutt_b2s(m->pathbuf), msgno) < sizeof(path)) &&
+ if ((snprintf(path, sizeof(path), "%s/%d", mailbox_path(m), msgno) < sizeof(path)) &&
(stat(path, &sb) == 0))
{
return (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->last_visited) <= 0);
if (!check_new)
return 0;
- if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0)
+ if (mh_read_sequences(&mhs, mailbox_path(m)) < 0)
return false;
m->msg_count = 0;
mhs_free_sequences(&mhs);
- dirp = opendir(mutt_b2s(m->pathbuf));
+ dirp = opendir(mailbox_path(m));
if (dirp)
{
while ((de = readdir(dirp)))
return 0;
}
- if (mkdir(mutt_b2s(m->pathbuf), S_IRWXU))
+ if (mkdir(mailbox_path(m), S_IRWXU))
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
+ snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", mailbox_path(m));
const int i = creat(tmp, S_IRWXU);
if (i == -1)
{
mutt_perror(tmp);
- rmdir(mutt_b2s(m->pathbuf));
+ rmdir(mailbox_path(m));
return -1;
}
close(i);
if (!C_CheckNew)
return 0;
- mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
+ mutt_str_strfcpy(buf, mailbox_path(m), sizeof(buf));
if (stat(buf, &st) == -1)
return -1;
/* create .mh_sequences when there isn't one. */
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox_path(m));
int i = stat(buf, &st_cur);
if ((i == -1) && (errno == ENOENT))
{
maildir_parse_dir(m, &last, NULL, &count, NULL);
maildir_delayed_parsing(m, &md, NULL);
- if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0)
+ if (mh_read_sequences(&mhs, mailbox_path(m)) < 0)
return -1;
mh_update_maildir(md, &mhs);
mhs_free_sequences(&mhs);
return mdata->mh_umask;
struct stat st;
- if (stat(mutt_b2s(m->pathbuf), &st))
+ if (stat(mailbox_path(m), &st))
{
- mutt_debug(LL_DEBUG1, "stat failed on %s\n", mutt_b2s(m->pathbuf));
+ mutt_debug(LL_DEBUG1, "stat failed on %s\n", mailbox_path(m));
return 077;
}
mode_t omask = umask(mh_umask(m));
while (true)
{
- snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mutt_b2s(m->pathbuf),
+ snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mailbox_path(m),
NONULL(ShortHostname), (int) getpid(), mutt_rand64());
fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
if (fd == -1)
snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(C_MhSeqReplied));
snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(C_MhSeqFlagged));
- snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mailbox_path(m));
FILE *fp_old = fopen(sequences, "r");
if (fp_old)
{
if (m->magic == MUTT_MAILDIR)
{
- snprintf(buf, sizeof(buf), "%s/%s", mutt_b2s(m->pathbuf), "cur");
+ snprintf(buf, sizeof(buf), "%s/%s", mailbox_path(m), "cur");
if (stat(buf, &st) == 0)
mutt_file_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME);
- snprintf(buf, sizeof(buf), "%s/%s", mutt_b2s(m->pathbuf), "new");
+ snprintf(buf, sizeof(buf), "%s/%s", mailbox_path(m), "new");
}
else
{
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", mailbox_path(m));
if (stat(buf, &st) == 0)
mutt_file_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME);
- mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
+ mutt_str_strfcpy(buf, mailbox_path(m), sizeof(buf));
}
if (stat(buf, &st) == 0)
if (subdir)
{
- mutt_buffer_printf(buf, "%s/%s", mutt_b2s(m->pathbuf), subdir);
+ mutt_buffer_printf(buf, "%s/%s", mailbox_path(m), subdir);
is_old = C_MarkOld ? (mutt_str_strcmp("cur", subdir) == 0) : false;
}
else
- mutt_buffer_strcpy(buf, mutt_b2s(m->pathbuf));
+ mutt_buffer_strcpy(buf, mailbox_path(m));
DIR *dirp = opendir(mutt_b2s(buf));
if (!dirp)
{
if (!m || !md || !*md || (m->magic != MUTT_MH) || (C_Sort != SORT_ORDER))
return;
- mutt_debug(LL_DEBUG3, "maildir: sorting %s into natural order\n", mutt_b2s(m->pathbuf));
+ mutt_debug(LL_DEBUG3, "maildir: sorting %s into natural order\n", mailbox_path(m));
*md = maildir_sort(*md, (size_t) -1, md_cmp_path);
}
bool sort = false;
#ifdef USE_HCACHE
- header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
+ header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL);
#endif
for (p = *md, count = 0; p; p = p->next, count++)
if (!sort)
{
- mutt_debug(LL_DEBUG3, "maildir: need to sort %s by inode\n", mutt_b2s(m->pathbuf));
+ mutt_debug(LL_DEBUG3, "maildir: need to sort %s by inode\n", mailbox_path(m));
p = maildir_sort(p, (size_t) -1, md_cmp_inode);
if (!last)
*md = p;
last->next = p;
sort = true;
p = skip_duplicates(p, &last);
- snprintf(fn, sizeof(fn), "%s/%s", mutt_b2s(m->pathbuf), p->email->path);
+ snprintf(fn, sizeof(fn), "%s/%s", mailbox_path(m), p->email->path);
}
- snprintf(fn, sizeof(fn), "%s/%s", mutt_b2s(m->pathbuf), p->email->path);
+ snprintf(fn, sizeof(fn), "%s/%s", mailbox_path(m), p->email->path);
#ifdef USE_HCACHE
struct stat lastchanged = { 0 };
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0);
}
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, count);
}
maildir_delayed_parsing(m, &md, &progress);
if (m->magic == MUTT_MH)
{
- if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0)
+ if (mh_read_sequences(&mhs, mailbox_path(m)) < 0)
{
maildir_free_maildir(&md);
return -1;
return -1;
}
- DIR *dirp = opendir(mutt_b2s(m->pathbuf));
+ DIR *dirp = opendir(mailbox_path(m));
if (!dirp)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
{
hi++;
snprintf(tmp, sizeof(tmp), "%u", hi);
- snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), tmp);
+ snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), tmp);
if (mutt_file_safe_rename(msg->path, path) == 0)
{
if (e)
}
else if (errno != EEXIST)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
}
{
mutt_buffer_printf(path, "%s/%lld.R%" PRIu64 ".%s%s", subdir, (long long) time(NULL),
mutt_rand64(), NONULL(ShortHostname), suffix);
- mutt_buffer_printf(full, "%s/%s", mutt_b2s(m->pathbuf), mutt_b2s(path));
+ mutt_buffer_printf(full, "%s/%s", mailbox_path(m), mutt_b2s(path));
mutt_debug(LL_DEBUG2, "renaming %s to %s\n", msg->path, mutt_b2s(full));
}
else if (errno != EEXIST)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
rc = -1;
goto cleanup;
}
{
char oldpath[PATH_MAX];
char partpath[PATH_MAX];
- snprintf(oldpath, sizeof(oldpath), "%s/%s", mutt_b2s(m->pathbuf), e->path);
+ snprintf(oldpath, sizeof(oldpath), "%s/%s", mailbox_path(m), e->path);
mutt_str_strfcpy(partpath, e->path, sizeof(partpath));
if (m->magic == MUTT_MAILDIR)
if ((m->magic == MUTT_MH) && (rc == 0))
{
char newpath[PATH_MAX];
- snprintf(newpath, sizeof(newpath), "%s/%s", mutt_b2s(m->pathbuf), e->path);
+ snprintf(newpath, sizeof(newpath), "%s/%s", mailbox_path(m), e->path);
rc = mutt_file_safe_rename(newpath, oldpath);
if (rc == 0)
mutt_str_replace(&e->path, partpath);
if (e->deleted && ((m->magic != MUTT_MAILDIR) || !C_MaildirTrash))
{
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), e->path);
+ snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), e->path);
if ((m->magic == MUTT_MAILDIR) || (C_MhPurge && (m->magic == MUTT_MH)))
{
#ifdef USE_HCACHE
if (*e->path != ',')
{
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/,%s", mutt_b2s(m->pathbuf), e->path);
+ snprintf(tmp, sizeof(tmp), "%s/,%s", mailbox_path(m), e->path);
unlink(tmp);
rename(path, tmp);
}
struct Email *e = m->emails[msgno];
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), e->path);
+ snprintf(path, sizeof(path), "%s/%s", mailbox_path(m), e->path);
msg->fp = fopen(path, "r");
if (!msg->fp && (errno == ENOENT) && is_maildir)
- msg->fp = maildir_open_find_message(mutt_b2s(m->pathbuf), e->path, NULL);
+ msg->fp = maildir_open_find_message(mailbox_path(m), e->path, NULL);
if (!msg->fp)
{
#ifdef USE_HCACHE
if ((m->magic == MUTT_MAILDIR) || (m->magic == MUTT_MH))
- hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
+ hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL);
#endif
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count);
}
{
int rc = 0;
#ifdef USE_HCACHE
- header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
+ header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL);
rc = mutt_hcache_store(hc, e->path, strlen(e->path), e, 0);
mutt_hcache_close(hc);
#endif
struct stat sb;
struct Progress progress;
- if (stat(mutt_b2s(m->pathbuf), &sb) == -1)
+ if (stat(mailbox_path(m), &sb) == -1)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
mutt_file_get_stat_timespec(&adata->atime, &sb, MUTT_STAT_ATIME);
if (!m->quiet)
{
char msgbuf[256];
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0);
}
struct Progress progress;
/* Save information about the folder at the time we opened it. */
- if (stat(mutt_b2s(m->pathbuf), &sb) == -1)
+ if (stat(mailbox_path(m), &sb) == -1)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
mutt_file_get_stat_timespec(&adata->atime, &sb, MUTT_STAT_ATIME);
if (!m->readonly)
- m->readonly = access(mutt_b2s(m->pathbuf), W_OK) ? true : false;
+ m->readonly = access(mailbox_path(m), W_OK) ? true : false;
if (!m->quiet)
{
char msgbuf[256];
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0);
}
case MUTT_MMDF:
cmp_headers = email_cmp_strict;
mutt_file_fclose(&adata->fp);
- adata->fp = mutt_file_fopen(mutt_b2s(m->pathbuf), "r");
+ adata->fp = mutt_file_fopen(mailbox_path(m), "r");
if (!adata->fp)
rc = -1;
else if (m->magic == MUTT_MBOX)
if (!st)
{
- if (stat(mutt_b2s(m->pathbuf), &st2) < 0)
+ if (stat(mailbox_path(m), &st2) < 0)
return;
st = &st2;
}
utimebuf.actime = utimebuf.modtime - 1;
}
- utime(mutt_b2s(m->pathbuf), &utimebuf);
+ utime(mailbox_path(m), &utimebuf);
}
/**
if (!np)
return NULL;
- if (mutt_str_strcmp(mutt_b2s(np->mailbox->pathbuf), path) != 0)
+ if (mutt_str_strcmp(mailbox_path(np->mailbox), path) != 0)
return NULL;
return a;
if (!adata)
return -1;
- adata->fp = fopen(mutt_b2s(m->pathbuf), "r+");
+ adata->fp = fopen(mailbox_path(m), "r+");
if (!adata->fp)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
mutt_sig_block();
if (!adata)
return -1;
- adata->fp = mutt_file_fopen(mutt_b2s(m->pathbuf), (flags & MUTT_NEWFOLDER) ? "w" : "a");
+ adata->fp = mutt_file_fopen(mailbox_path(m), (flags & MUTT_NEWFOLDER) ? "w" : "a");
if (!adata->fp)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
if (mbox_lock_mailbox(m, true, true) != false)
{
- mutt_error(_("Couldn't lock %s"), mutt_b2s(m->pathbuf));
+ mutt_error(_("Couldn't lock %s"), mailbox_path(m));
mutt_file_fclose(&adata->fp);
return -1;
}
bool unlock = false;
bool modified = false;
- if (stat(mutt_b2s(m->pathbuf), &st) == 0)
+ if (stat(mailbox_path(m), &st) == 0)
{
if ((mutt_file_stat_timespec_compare(&st, MUTT_STAT_MTIME, &m->mtime) == 0) &&
(st.st_size == m->size))
/* need to open the file for writing in such a way that it does not truncate
* the file, so use read-write mode. */
- adata->fp = freopen(mutt_b2s(m->pathbuf), "r+", adata->fp);
+ adata->fp = freopen(mailbox_path(m), "r+", adata->fp);
if (!adata->fp)
{
mx_fastclose_mailbox(m);
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count);
}
fp = NULL;
/* Save the state of this folder. */
- if (stat(mutt_b2s(m->pathbuf), &statbuf) == -1)
+ if (stat(mailbox_path(m), &statbuf) == -1)
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
unlink(tempfile);
goto bail;
}
mbox_reset_atime(m, &statbuf);
/* reopen the mailbox in read-only mode */
- adata->fp = fopen(mutt_b2s(m->pathbuf), "r");
+ adata->fp = fopen(mailbox_path(m), "r");
if (!adata->fp)
{
unlink(tempfile);
if (C_CheckMboxSize)
{
- struct Mailbox *m_tmp = mailbox_find(mutt_b2s(m->pathbuf));
+ struct Mailbox *m_tmp = mailbox_find(mailbox_path(m));
if (m_tmp && !m_tmp->has_new)
mailbox_update(m_tmp);
}
FREE(&new_offset);
FREE(&old_offset);
- adata->fp = freopen(mutt_b2s(m->pathbuf), "r", adata->fp);
+ adata->fp = freopen(mailbox_path(m), "r", adata->fp);
if (!adata->fp)
{
mutt_error(_("Could not reopen mailbox"));
struct utimbuf ut;
ut.actime = adata->atime.tv_sec;
ut.modtime = m->mtime.tv_sec;
- utime(mutt_b2s(m->pathbuf), &ut);
+ utime(mailbox_path(m), &ut);
#endif
}
static int mbox_mbox_check_stats(struct Mailbox *m, int flags)
{
struct stat sb = { 0 };
- if (stat(mutt_b2s(m->pathbuf), &sb) != 0)
+ if (stat(mailbox_path(m), &sb) != 0)
return -1;
bool new_or_changed;
int orig_flagged = m_check->msg_flagged;
#endif
- enum MailboxType mb_magic = mx_path_probe(mutt_b2s(m_check->pathbuf), NULL);
+ enum MailboxType mb_magic = mx_path_probe(mailbox_path(m_check), NULL);
switch (mb_magic)
{
default:
m_check->has_new = false;
- if ((stat(mutt_b2s(m_check->pathbuf), &sb) != 0) ||
+ if ((stat(mailbox_path(m_check), &sb) != 0) ||
(S_ISREG(sb.st_mode) && (sb.st_size == 0)) ||
((m_check->magic == MUTT_UNKNOWN) &&
- ((m_check->magic = mx_path_probe(mutt_b2s(m_check->pathbuf), NULL)) <= 0)))
+ ((m_check->magic = mx_path_probe(mailbox_path(m_check), NULL)) <= 0)))
{
/* if the mailbox still doesn't exist, set the newly created flag to be
* ready for when it does. */
if (!m_cur || mutt_buffer_is_empty(m_cur->pathbuf) ||
(((m_check->magic == MUTT_IMAP) || (m_check->magic == MUTT_NNTP) ||
(m_check->magic == MUTT_NOTMUCH) || (m_check->magic == MUTT_POP)) ?
- (mutt_str_strcmp(mutt_b2s(m_check->pathbuf), mutt_b2s(m_cur->pathbuf)) != 0) :
+ (mutt_str_strcmp(mailbox_path(m_check), mailbox_path(m_cur)) != 0) :
((sb.st_dev != ctx_sb->st_dev) || (sb.st_ino != ctx_sb->st_ino))))
{
switch (m_check->magic)
#ifdef USE_NNTP
|| (m_cur->magic == MUTT_NNTP)
#endif
- || stat(mutt_b2s(m_cur->pathbuf), &contex_sb) != 0)
+ || stat(mailbox_path(m_cur), &contex_sb) != 0)
{
contex_sb.st_dev = 0;
contex_sb.st_ino = 0;
if (!np->mailbox->has_new || (have_unnotified && np->mailbox->notified))
continue;
- mutt_buffer_strcpy(path, mutt_b2s(np->mailbox->pathbuf));
+ mutt_buffer_strcpy(path, mailbox_path(np->mailbox));
mutt_buffer_pretty_mailbox(path);
if (!first && (MuttMessageWindow->cols >= 7) &&
mutt_buffer_expand_path(np->mailbox->pathbuf);
if ((found || (pass > 0)) && np->mailbox->has_new)
{
- mutt_buffer_strcpy(s, mutt_b2s(np->mailbox->pathbuf));
+ mutt_buffer_strcpy(s, mailbox_path(np->mailbox));
mutt_buffer_pretty_mailbox(s);
return;
}
- if (mutt_str_strcmp(mutt_b2s(s), mutt_b2s(np->mailbox->pathbuf)) == 0)
+ if (mutt_str_strcmp(mutt_b2s(s), mailbox_path(np->mailbox)) == 0)
found = true;
}
neomutt_mailboxlist_clear(&ml);
m->append = true;
if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR))
{
- m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL);
+ m->magic = mx_path_probe(mailbox_path(m), NULL);
if (m->magic == MUTT_UNKNOWN)
{
}
else
{
- mutt_error(_("%s is not a mailbox"), mutt_b2s(m->pathbuf));
+ mutt_error(_("%s is not a mailbox"), mailbox_path(m));
return -1;
}
}
if (m->magic == MUTT_MAILBOX_ERROR)
{
- if (stat(mutt_b2s(m->pathbuf), &sb) == -1)
+ if (stat(mailbox_path(m), &sb) == -1)
{
if (errno == ENOENT)
{
}
else
{
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
return -1;
}
}
if (m->magic == MUTT_UNKNOWN)
{
- m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL);
+ m->magic = mx_path_probe(mailbox_path(m), NULL);
m->mx_ops = mx_get_ops(m->magic);
}
if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR) || !m->mx_ops)
{
if (m->magic == MUTT_MAILBOX_ERROR)
- mutt_perror(mutt_b2s(m->pathbuf));
+ mutt_perror(mailbox_path(m));
else if ((m->magic == MUTT_UNKNOWN) || !m->mx_ops)
- mutt_error(_("%s is not a mailbox"), mutt_b2s(m->pathbuf));
+ mutt_error(_("%s is not a mailbox"), mailbox_path(m));
mx_fastclose_mailbox(m);
ctx_free(&ctx);
OptForceRefresh = true;
if (!m->quiet)
- mutt_message(_("Reading %s..."), mutt_b2s(m->pathbuf));
+ mutt_message(_("Reading %s..."), mailbox_path(m));
int rc = m->mx_ops->mbox_open(ctx->mailbox);
m->opened++;
mutt_clear_error();
if (rc == -2)
{
- mutt_error(_("Reading from %s interrupted..."), mutt_b2s(m->pathbuf));
+ mutt_error(_("Reading from %s interrupted..."), mailbox_path(m));
mutt_sort_headers(ctx, true);
}
}
if (!m->quiet)
{
/* L10N: Displayed before/as a mailbox is being synced */
- mutt_message(_("Writing %s..."), mutt_b2s(m->pathbuf));
+ mutt_message(_("Writing %s..."), mailbox_path(m));
}
int rc = m->mx_ops->mbox_sync(m, index_hint);
if ((rc != 0) && !m->quiet)
{
/* L10N: Displayed if a mailbox sync fails */
- mutt_error(_("Unable to write %s"), mutt_b2s(m->pathbuf));
+ mutt_error(_("Unable to write %s"), mailbox_path(m));
}
return rc;
return -1;
}
- if ((lstat(mutt_b2s(m->pathbuf), &stc) == 0) && (stc.st_ino == st.st_ino) &&
+ if ((lstat(mailbox_path(m), &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 != 0) && (C_Move != MUTT_NO))
{
bool is_spool;
- char *p = mutt_find_hook(MUTT_MBOX_HOOK, mutt_b2s(m->pathbuf));
+ char *p = mutt_find_hook(MUTT_MBOX_HOOK, mailbox_path(m));
if (p)
{
is_spool = true;
else
{
mutt_str_strfcpy(mbox, C_Mbox, sizeof(mbox));
- is_spool = mutt_is_spool(mutt_b2s(m->pathbuf)) && !mutt_is_spool(mbox);
+ is_spool = mutt_is_spool(mailbox_path(m)) && !mutt_is_spool(mbox);
}
if (is_spool && (mbox[0] != '\0'))
/* copy mails to the trash before expunging */
if (purge && (m->msg_deleted != 0) &&
- (mutt_str_strcmp(mutt_b2s(m->pathbuf), C_Trash) != 0))
+ (mutt_str_strcmp(mailbox_path(m), C_Trash) != 0))
{
if (trash_append(ctx->mailbox) != 0)
return -1;
if ((m->msg_count == m->msg_deleted) &&
((m->magic == MUTT_MMDF) || (m->magic == MUTT_MBOX)) &&
- !mutt_is_spool(mutt_b2s(m->pathbuf)) && !C_SaveEmpty)
+ !mutt_is_spool(mailbox_path(m)) && !C_SaveEmpty)
{
- mutt_file_unlink_empty(mutt_b2s(m->pathbuf));
+ mutt_file_unlink_empty(mailbox_path(m));
}
#ifdef USE_SIDEBAR
deleted = m->msg_deleted;
if (purge && (m->msg_deleted != 0) &&
- (mutt_str_strcmp(mutt_b2s(m->pathbuf), C_Trash) != 0))
+ (mutt_str_strcmp(mailbox_path(m), C_Trash) != 0))
{
if (trash_append(m) != 0)
return -1;
if ((m->msg_count == m->msg_deleted) &&
((m->magic == MUTT_MBOX) || (m->magic == MUTT_MMDF)) &&
- !mutt_is_spool(mutt_b2s(m->pathbuf)) && !C_SaveEmpty)
+ !mutt_is_spool(mailbox_path(m)) && !C_SaveEmpty)
{
- unlink(mutt_b2s(m->pathbuf));
+ unlink(mailbox_path(m));
mx_fastclose_mailbox(m);
return 0;
}
if (m->realpath)
mutt_str_strfcpy(buf, m->realpath, sizeof(buf));
else
- mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
+ mutt_str_strfcpy(buf, mailbox_path(m), sizeof(buf));
int rc = mx_path_canon(buf, sizeof(buf), folder, &m->magic);
void *hc = NULL;
anum_t first, last, count = 0;
- struct Url *url = url_parse(mutt_b2s(m->pathbuf));
+ struct Url *url = url_parse(mailbox_path(m));
if (!url || !url->host || !url->path ||
!((url->scheme == U_NNTP) || (url->scheme == U_NNTPS)))
{
url_free(&url);
- mutt_error(_("%s is an invalid newsgroup specification"), mutt_b2s(m->pathbuf));
+ mutt_error(_("%s is an invalid newsgroup specification"), mailbox_path(m));
return -1;
}
static header_cache_t *nm_hcache_open(struct Mailbox *m)
{
#ifdef USE_HCACHE
- return mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
+ return mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL);
#else
return NULL;
#endif
if (m->mdata)
return 0;
- m->mdata = nm_mdata_new(mutt_b2s(m->pathbuf));
+ m->mdata = nm_mdata_new(mailbox_path(m));
if (!m->mdata)
return -1;
int limit = C_NmDbLimit;
mutt_debug(LL_DEBUG1, "nm: count\n");
- url = url_parse(mutt_b2s(m->pathbuf));
+ url = url_parse(mailbox_path(m));
if (!url)
{
- mutt_error(_("failed to parse notmuch uri: %s"), mutt_b2s(m->pathbuf));
+ mutt_error(_("failed to parse notmuch uri: %s"), mailbox_path(m));
goto done;
}
int rc = 0;
struct Progress progress;
- char *uri = mutt_str_strdup(mutt_b2s(m->pathbuf));
+ char *uri = mutt_str_strdup(mailbox_path(m));
bool changed = false;
mutt_debug(LL_DEBUG1, "nm: sync start\n");
{
char msgbuf[PATH_MAX + 64];
/* all is in this function so we don't use data->progress here */
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf));
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mailbox_path(m));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count);
}
}
else
{
- char *escaped_folder = mutt_path_escape(mutt_b2s(Context->mailbox->pathbuf));
+ char *escaped_folder = mutt_path_escape(mailbox_path(Context->mailbox));
mutt_debug(LL_DEBUG2, "escaped folder path: %s\n", escaped_folder);
mutt_buffer_addch(&cmd_buf, '\'');
mutt_buffer_addstr(&cmd_buf, escaped_folder);
struct Progress progress;
#ifdef USE_HCACHE
- header_cache_t *hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf));
+ header_cache_t *hc = pop_hcache_open(adata, mailbox_path(m));
#endif
time(&adata->check_time);
a->adata = adata;
a->free_adata = pop_adata_free;
- struct Url *url = url_parse(mutt_b2s(m->pathbuf));
+ struct Url *url = url_parse(mailbox_path(m));
if (!url)
return 0;
struct ConnAccount acct = { { 0 } };
struct Url url;
- if (pop_parse_path(mutt_b2s(m->pathbuf), &acct))
+ if (pop_parse_path(mailbox_path(m), &acct))
{
- mutt_error(_("%s is an invalid POP path"), mutt_b2s(m->pathbuf));
+ mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
return -1;
}
url_tostring(&url, buf, sizeof(buf), 0);
mutt_buffer_strcpy(m->pathbuf, buf);
- mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf));
+ mutt_str_replace(&m->realpath, mailbox_path(m));
struct PopAccountData *adata = m->account->adata;
if (!adata)
MUTT_PROGRESS_MSG, C_WriteInc, num_deleted);
#ifdef USE_HCACHE
- hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf));
+ hc = pop_hcache_open(adata, mailbox_path(m));
#endif
for (i = 0, j = 0, rc = 0; (rc == 0) && (i < m->msg_count); i++)
#ifdef USE_HCACHE
struct PopAccountData *adata = pop_adata_get(m);
struct PopEmailData *edata = e->edata;
- header_cache_t *hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf));
+ header_cache_t *hc = pop_hcache_open(adata, mailbox_path(m));
rc = mutt_hcache_store(hc, edata->uid, strlen(edata->uid), e, 0);
mutt_hcache_close(hc);
#endif
{
case SORT_COUNT:
if (m2->msg_count == m1->msg_count)
- rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
+ rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2));
else
rc = (m2->msg_count - m1->msg_count);
break;
case SORT_UNREAD:
if (m2->msg_unread == m1->msg_unread)
- rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
+ rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2));
else
rc = (m2->msg_unread - m1->msg_unread);
break;
break;
case SORT_FLAGGED:
if (m2->msg_flagged == m1->msg_flagged)
- rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
+ rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2));
else
rc = (m2->msg_flagged - m1->msg_flagged);
break;
case SORT_PATH:
{
- rc = mutt_inbox_cmp(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
+ rc = mutt_inbox_cmp(mailbox_path(m1), mailbox_path(m2));
if (rc == 0)
- rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
+ rc = mutt_str_strcoll(mailbox_path(m1), mailbox_path(m2));
break;
}
}
continue;
}
- if (mutt_list_find(&SidebarWhitelist, mutt_b2s(sbe->mailbox->pathbuf)) ||
+ if (mutt_list_find(&SidebarWhitelist, mailbox_path(sbe->mailbox)) ||
mutt_list_find(&SidebarWhitelist, sbe->mailbox->name))
{
/* Explicitly asked to be visible */
else if (m->msg_flagged > 0)
SET_COLOR(MT_COLOR_FLAGGED);
else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) &&
- (mutt_str_strcmp(mutt_b2s(m->pathbuf), C_Spoolfile) == 0))
+ (mutt_str_strcmp(mailbox_path(m), C_Spoolfile) == 0))
{
SET_COLOR(MT_COLOR_SB_SPOOLFILE);
}
/* check whether C_Folder is a prefix of the current folder's path */
bool maildir_is_prefix = false;
if ((mutt_buffer_len(m->pathbuf) > maildirlen) &&
- (mutt_str_strncmp(C_Folder, mutt_b2s(m->pathbuf), maildirlen) == 0) && C_SidebarDelimChars &&
- strchr(C_SidebarDelimChars, mutt_b2s(m->pathbuf)[maildirlen]))
+ (mutt_str_strncmp(C_Folder, mailbox_path(m), maildirlen) == 0) && C_SidebarDelimChars &&
+ strchr(C_SidebarDelimChars, mailbox_path(m)[maildirlen]))
{
maildir_is_prefix = true;
}
if (C_SidebarShortPath)
{
/* disregard a trailing separator, so strlen() - 2 */
- sidebar_folder_name = mutt_b2s(m->pathbuf);
+ sidebar_folder_name = mailbox_path(m);
for (int i = mutt_str_strlen(sidebar_folder_name) - 2; i >= 0; i--)
{
if (C_SidebarDelimChars && strchr(C_SidebarDelimChars, sidebar_folder_name[i]))
}
else if ((C_SidebarComponentDepth > 0) && C_SidebarDelimChars)
{
- sidebar_folder_name = mutt_b2s(m->pathbuf) + maildir_is_prefix * (maildirlen + 1);
+ sidebar_folder_name = mailbox_path(m) + maildir_is_prefix * (maildirlen + 1);
for (int i = 0; i < C_SidebarComponentDepth; i++)
{
char *chars_after_delim = strpbrk(sidebar_folder_name, C_SidebarDelimChars);
}
}
else
- sidebar_folder_name = mutt_b2s(m->pathbuf) + maildir_is_prefix * (maildirlen + 1);
+ sidebar_folder_name = mailbox_path(m) + maildir_is_prefix * (maildirlen + 1);
if (m->name)
{
else if (maildir_is_prefix && C_SidebarFolderIndent)
{
int lastsep = 0;
- const char *tmp_folder_name = mutt_b2s(m->pathbuf) + maildirlen + 1;
+ const char *tmp_folder_name = mailbox_path(m) + maildirlen + 1;
int tmplen = (int) mutt_str_strlen(tmp_folder_name) - 1;
for (int i = 0; i < tmplen; i++)
{
}
else if (m && !mutt_buffer_is_empty(m->pathbuf))
{
- mutt_str_strfcpy(tmp, mutt_b2s(m->pathbuf), sizeof(tmp));
+ mutt_str_strfcpy(tmp, mailbox_path(m), sizeof(tmp));
mutt_pretty_mailbox(tmp, sizeof(tmp));
}
else