Rename to struct Buffer->pathbuf to make it clear the field is a struct Buffer, and
to make sure to catch and review all usages.
There are still uses of pathbuf that are truncating and need to be
fixed, for example in browser.c and buffy.c.
Fix up sidebar usage in one place, that was pointing inside the
struct Mailbox->path with a char *. At the same time, change their "short
folder" computation to also use a struct Buffer.
Co-authored-by: Richard Russon <rich@flatcap.org>
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
{
- if (mutt_str_strcmp(mutt_b2s(buf), np->mailbox->path) != 0)
+ if (mutt_str_strcmp(mutt_b2s(buf), mutt_b2s(np->mailbox->pathbuf)) != 0)
break;
}
}
char buf[PATH_MAX];
- mutt_str_strfcpy(buf, np->mailbox->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(np->mailbox->pathbuf), sizeof(buf));
if (C_BrowserAbbreviateMailboxes)
mutt_pretty_mailbox(buf, sizeof(buf));
continue;
case MUTT_NOTMUCH:
case MUTT_NNTP:
- add_folder(menu, state, np->mailbox->path, np->mailbox->desc, NULL,
- np->mailbox, NULL);
+ add_folder(menu, state, mutt_b2s(np->mailbox->pathbuf),
+ np->mailbox->desc, NULL, np->mailbox, NULL);
continue;
default: /* Continue */
break;
}
- if (lstat(np->mailbox->path, &s) == -1)
+ if (lstat(mutt_b2s(np->mailbox->pathbuf), &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", np->mailbox->path);
+ mutt_buffer_printf(md, "%s/new", mutt_b2s(np->mailbox->pathbuf));
if (stat(mutt_b2s(md), &s) < 0)
s.st_mtime = 0;
- mutt_buffer_printf(md, "%s/cur", np->mailbox->path);
+ mutt_buffer_printf(md, "%s/cur", mutt_b2s(np->mailbox->pathbuf));
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/AllMailboxes/mailbox->account here for now.
// Let's just protect neomutt against crash for now. #1417
- if (mutt_str_strcmp(Context->mailbox->path, state.entry[nentry].name) == 0)
+ if (mutt_str_strcmp(mutt_b2s(Context->mailbox->pathbuf),
+ state.entry[nentry].name) == 0)
{
mutt_error(_("Can't delete currently selected mailbox"));
break;
if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->mailbox->magic == MUTT_NNTP))
#endif
{
- mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
}
buf[0] = '\0';
if (Context)
{
- mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
}
if (actx->idxlen)
char tmp[PATH_MAX];
/* Setup the right paths */
- mutt_str_replace(&m->realpath, m->path);
+ mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf));
/* We will uncompress to /tmp */
mutt_mktemp(tmp, sizeof(tmp));
- mutt_str_strfcpy(m->path, tmp, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, tmp);
- FILE *fp = mutt_file_fopen(m->path, "w");
+ FILE *fp = mutt_file_fopen(mutt_b2s(m->pathbuf), "w");
if (!fp)
return -1;
return m->compress_info;
/* Open is compulsory */
- const char *o = find_hook(MUTT_OPEN_HOOK, m->path);
+ const char *o = find_hook(MUTT_OPEN_HOOK, mutt_b2s(m->pathbuf));
if (!o)
return NULL;
- const char *c = find_hook(MUTT_CLOSE_HOOK, m->path);
- const char *a = find_hook(MUTT_APPEND_HOOK, m->path);
+ const char *c = find_hook(MUTT_CLOSE_HOOK, mutt_b2s(m->pathbuf));
+ const char *a = find_hook(MUTT_APPEND_HOOK, mutt_b2s(m->pathbuf));
struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo));
m->compress_info = ci;
break;
case 't':
/* Plaintext, temporary file */
- stuffing = mutt_path_escape(m->path);
+ stuffing = mutt_path_escape(mutt_b2s(m->pathbuf));
break;
}
snprintf(buf, buflen, "%s", NONULL(stuffing));
if (ci->cmd_append || ci->cmd_close)
return true;
- mutt_error(_("Can't append without an append-hook or close-hook : %s"), m->path);
+ mutt_error(_("Can't append without an append-hook or close-hook : %s"),
+ mutt_b2s(m->pathbuf));
return false;
}
return -1;
/* If there's no close-hook, or the file isn't writable */
- if (!ci->cmd_close || (access(m->path, W_OK) != 0))
+ if (!ci->cmd_close || (access(mutt_b2s(m->pathbuf), W_OK) != 0))
m->readonly = true;
if (setup_paths(m) != 0)
unlock_realpath(m);
- m->magic = mx_path_probe(m->path, NULL);
+ m->magic = mx_path_probe(mutt_b2s(m->pathbuf), 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(m->path);
+ remove(mutt_b2s(m->pathbuf));
free_compress_info(m);
return -1;
}
/* To append we need an append-hook or a close-hook */
if (!ci->cmd_append && !ci->cmd_close)
{
- mutt_error(_("Can't append without an append-hook or close-hook : %s"), m->path);
+ mutt_error(_("Can't append without an append-hook or close-hook : %s"),
+ mutt_b2s(m->pathbuf));
goto cmoa_fail1;
}
mutt_error(_("Compress command failed: %s"), ci->cmd_open);
goto cmoa_fail2;
}
- m->magic = mx_path_probe(m->path, NULL);
+ m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL);
}
else
m->magic = C_MboxType;
cmoa_fail2:
/* remove the partial uncompressed file */
- remove(m->path);
+ remove(mutt_b2s(m->pathbuf));
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"), m->path);
+ mutt_error(_("Error. Preserving temporary file: %s"), mutt_b2s(m->pathbuf));
}
else
- remove(m->path);
+ remove(mutt_b2s(m->pathbuf));
unlock_realpath(m);
}
else
{
/* If the file was removed, remove the compressed folder too */
- if ((access(m->path, F_OK) != 0) && !C_SaveEmpty)
+ if ((access(mutt_b2s(m->pathbuf), F_OK) != 0) && !C_SaveEmpty)
{
remove(m->realpath);
}
else
{
- remove(m->path);
+ remove(mutt_b2s(m->pathbuf));
}
}
case 'b':
if (m)
{
- p = strrchr(m->path, '/');
+ p = strrchr(mutt_b2s(m->pathbuf), '/');
if (p)
mutt_str_strfcpy(buf, p + 1, buflen);
else
- mutt_str_strfcpy(buf, m->path, buflen);
+ mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), buflen);
}
else
mutt_str_strfcpy(buf, "(null)", buflen);
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
{
- if (mutt_str_strcmp(tmp, np->mailbox->path) == 0)
+ if (mutt_str_strcmp(tmp, mutt_b2s(np->mailbox->pathbuf)) == 0)
break;
}
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
{
- if (!mutt_str_startswith(np->mailbox->path, buf, CASE_MATCH))
+ if (!mutt_str_startswith(mutt_b2s(np->mailbox->pathbuf), buf, CASE_MATCH))
continue;
if (rc)
{
- mutt_str_strfcpy(buf, np->mailbox->path, buflen);
+ mutt_str_strfcpy(buf, mutt_b2s(np->mailbox->pathbuf), buflen);
rc = 0;
}
else
- longest_common_prefix(buf, np->mailbox->path, matchlen, buflen);
+ longest_common_prefix(buf, mutt_b2s(np->mailbox->pathbuf), matchlen, buflen);
}
#if 0
/* 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, m->path);
+ mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mutt_b2s(m->pathbuf));
goto out;
}
struct ConnAccount conn_account;
char mailbox[PATH_MAX];
- if (imap_parse_path(m->path, &conn_account, mailbox, sizeof(mailbox)) < 0)
+ if (imap_parse_path(mutt_b2s(m->pathbuf), &conn_account, mailbox, sizeof(mailbox)) < 0)
return -1;
adata = imap_adata_new();
if (!m->mdata)
{
- struct Url *url = url_parse(m->path);
+ struct Url *url = url_parse(mutt_b2s(m->pathbuf));
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_str_strfcpy(m->path, buf, sizeof(m->path));
- mutt_str_replace(&m->realpath, m->path);
+ mutt_buffer_strcpy(m->pathbuf, buf);
+ mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf));
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, m->path);
+ mutt_debug(LL_DEBUG3, "%s not same server as %s\n", dest, mutt_b2s(m->pathbuf));
return 1;
}
if (m)
{
magic = m->magic;
- mutt_str_strfcpy(buf, m->path, buflen);
+ mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), buflen);
}
else
{
}
/* keepalive failure in mutt_enter_fname may kill connection. #3028 */
- if (Context && (Context->mailbox->path[0] == '\0'))
+ if (Context && (mutt_buffer_is_empty(Context->mailbox->pathbuf)))
ctx_free(&Context);
if (Context)
new_last_folder = mutt_str_strdup(Context->mailbox->realpath);
else
#endif
- new_last_folder = mutt_str_strdup(Context->mailbox->path);
+ new_last_folder = mutt_str_strdup(mutt_b2s(Context->mailbox->pathbuf));
*oldcount = Context ? Context->mailbox->msg_count : 0;
int check = mx_mbox_close(&Context);
check = mx_mbox_check(Context->mailbox, &index_hint);
if (check < 0)
{
- if (!Context->mailbox || (Context->mailbox->path[0] == '\0'))
+ if (!Context->mailbox || (mutt_buffer_is_empty(Context->mailbox->pathbuf)))
{
/* fatal error occurred */
ctx_free(&Context);
}
/* check for a fatal error, or all messages deleted */
- if (Context->mailbox->path[0] == '\0')
+ if (mutt_buffer_is_empty(Context->mailbox->pathbuf))
ctx_free(&Context);
/* if we were in the pager, redisplay the message */
buf[0] = '\0';
if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context &&
- (Context->mailbox->path[0] != '\0'))
+ mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
- mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
mutt_mailbox(Context ? Context->mailbox : NULL, buf, sizeof(buf));
if (buf[0] == '\0')
m = mutt_sb_get_highlight();
if (!m)
break;
- mutt_str_strfcpy(buf, m->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
/* Mark the selected dir for the neomutt browser */
- mutt_browser_select_dir(m->path);
+ mutt_browser_select_dir(mutt_b2s(m->pathbuf));
}
#endif
else
{
- if (C_ChangeFolderNext && Context && (Context->mailbox->path[0] != '\0'))
+ if (C_ChangeFolderNext && Context &&
+ mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
- mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(Context->mailbox->pathbuf), sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
}
#ifdef USE_NNTP
continue;
}
- mutt_str_strfcpy(m->path, buf->data, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, buf->data);
/* int rc = */ mx_path_canon2(m, C_Folder);
bool new_account = false;
/* Compare against path or desc? Ensure 'tmp' is valid */
if (!clear_this && tmp_valid)
{
- clear_this = (mutt_str_strcasecmp(tmp, np->mailbox->path) == 0) ||
+ clear_this = (mutt_str_strcasecmp(tmp, mutt_b2s(np->mailbox->pathbuf)) == 0) ||
(mutt_str_strcasecmp(tmp, np->mailbox->desc) == 0);
}
{
if (mp->mailbox->magic == MUTT_NOTMUCH)
{
- cs_str_string_set(Config, "spoolfile", mp->mailbox->path, NULL);
+ cs_str_string_set(Config, "spoolfile", mutt_b2s(mp->mailbox->pathbuf), NULL);
break;
}
}
{
struct Mailbox *m = mutt_mem_calloc(1, sizeof(struct Mailbox));
+ m->pathbuf = mutt_buffer_new();
+
return m;
}
struct Mailbox *m = *ptr;
mutt_mailbox_changed(m, MBN_CLOSED);
+ mutt_buffer_free(&m->pathbuf);
FREE(&m->desc);
if (m->mdata && m->free_mdata)
m->free_mdata(&m->mdata);
int orig_flagged = m_check->msg_flagged;
#endif
- enum MailboxType mb_magic = mx_path_probe(m_check->path, NULL);
+ enum MailboxType mb_magic = mx_path_probe(mutt_b2s(m_check->pathbuf), NULL);
switch (mb_magic)
{
default:
m_check->has_new = false;
- if ((stat(m_check->path, &sb) != 0) || (S_ISREG(sb.st_mode) && (sb.st_size == 0)) ||
+ if ((stat(mutt_b2s(m_check->pathbuf), &sb) != 0) ||
+ (S_ISREG(sb.st_mode) && (sb.st_size == 0)) ||
((m_check->magic == MUTT_UNKNOWN) &&
- ((m_check->magic = mx_path_probe(m_check->path, NULL)) <= 0)))
+ ((m_check->magic = mx_path_probe(mutt_b2s(m_check->pathbuf), NULL)) <= 0)))
{
/* if the mailbox still doesn't exist, set the newly created flag to be
* ready for when it does. */
}
/* check to see if the folder is the currently selected folder before polling */
- if (!m_cur || (m_cur->path[0] == '\0') ||
+ 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(m_check->path, m_cur->path) != 0) :
+ (mutt_str_strcmp(mutt_b2s(m_check->pathbuf), mutt_b2s(m_cur->pathbuf)) != 0) :
((sb.st_dev != ctx_sb->st_dev) || (sb.st_ino != ctx_sb->st_ino))))
{
switch (m_check->magic)
default:; /* do nothing */
}
}
- else if (C_CheckMboxSize && m_cur && (m_cur->path[0] != '\0'))
+ else if (C_CheckMboxSize && m_cur && mutt_buffer_is_empty(m_cur->pathbuf))
m_check->size = (off_t) sb.st_size; /* update the size of current folder */
#ifdef USE_SIDEBAR
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
{
- if ((stat(np->mailbox->path, &tmp_sb) == 0) &&
+ if ((stat(mutt_b2s(np->mailbox->pathbuf), &tmp_sb) == 0) &&
(sb.st_dev == tmp_sb.st_dev) && (sb.st_ino == tmp_sb.st_ino))
{
return np->mailbox;
if (!m)
return;
- if (stat(m->path, &sb) == 0)
+ if (stat(mutt_b2s(m->pathbuf), &sb) == 0)
m->size = (off_t) sb.st_size;
else
m->size = 0;
#ifdef USE_NNTP
|| (m_cur->magic == MUTT_NNTP)
#endif
- || stat(m_cur->path, &contex_sb) != 0)
+ || stat(mutt_b2s(m_cur->pathbuf), &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_str_strfcpy(path, np->mailbox->path, sizeof(path));
+ mutt_str_strfcpy(path, mutt_b2s(np->mailbox->pathbuf), sizeof(path));
mutt_pretty_mailbox(path, sizeof(path));
if (!first && (MuttMessageWindow->cols >= 7) &&
{
if (np->mailbox->magic == MUTT_NOTMUCH) /* only match real mailboxes */
continue;
- mutt_expand_path(np->mailbox->path, sizeof(np->mailbox->path));
+ mutt_buffer_expand_path(np->mailbox->pathbuf);
if ((found || pass) && np->mailbox->has_new)
{
- mutt_buffer_strcpy(s, np->mailbox->path);
+ mutt_buffer_strcpy(s, mutt_b2s(np->mailbox->pathbuf));
mutt_buffer_pretty_mailbox(s);
return;
}
- if (mutt_str_strcmp(mutt_b2s(s), np->mailbox->path) == 0)
+ if (mutt_str_strcmp(mutt_b2s(s), mutt_b2s(np->mailbox->pathbuf)) == 0)
found = 1;
}
}
*/
struct Mailbox
{
- char path[PATH_MAX];
+ struct Buffer *pathbuf;
char *realpath; ///< used for duplicate detection, context comparison, and the sidebar
char *desc;
off_t size;
struct Buffer *path = mutt_buffer_pool_get();
struct Buffer *msgpath = mutt_buffer_pool_get();
- mutt_buffer_printf(path, "%s/%s", m->path, dir_name);
+ mutt_buffer_printf(path, "%s/%s", mutt_b2s(m->pathbuf), 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", m->path, mutt_b2s(partpath));
- mutt_buffer_printf(oldpath, "%s/%s", m->path, e->path);
+ 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);
if (mutt_str_strcmp(mutt_b2s(fullpath), mutt_b2s(oldpath)) == 0)
{
return 0;
}
- if (mkdir(m->path, S_IRWXU))
+ if (mkdir(mutt_b2s(m->pathbuf), S_IRWXU))
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/cur", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf));
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- rmdir(m->path);
+ rmdir(mutt_b2s(m->pathbuf));
return -1;
}
- snprintf(tmp, sizeof(tmp), "%s/new", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/new", mutt_b2s(m->pathbuf));
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- snprintf(tmp, sizeof(tmp), "%s/cur", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf));
rmdir(tmp);
- rmdir(m->path);
+ rmdir(mutt_b2s(m->pathbuf));
return -1;
}
- snprintf(tmp, sizeof(tmp), "%s/tmp", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/tmp", mutt_b2s(m->pathbuf));
if (mkdir(tmp, S_IRWXU))
{
mutt_perror(tmp);
- snprintf(tmp, sizeof(tmp), "%s/cur", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/cur", mutt_b2s(m->pathbuf));
rmdir(tmp);
- snprintf(tmp, sizeof(tmp), "%s/new", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/new", mutt_b2s(m->pathbuf));
rmdir(tmp);
- rmdir(m->path);
+ rmdir(mutt_b2s(m->pathbuf));
return -1;
}
return 0;
struct Buffer *buf = mutt_buffer_pool_get();
- mutt_buffer_printf(buf, "%s/new", m->path);
+ mutt_buffer_printf(buf, "%s/new", mutt_b2s(m->pathbuf));
if (stat(mutt_b2s(buf), &st_new) == -1)
{
mutt_buffer_pool_release(&buf);
return -1;
}
- mutt_buffer_printf(buf, "%s/cur", m->path);
+ mutt_buffer_printf(buf, "%s/cur", mutt_b2s(m->pathbuf));
if (stat(mutt_b2s(buf), &st_cur) == -1)
{
mutt_buffer_pool_release(&buf);
mode_t omask = umask(mh_umask(m));
while (true)
{
- snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s", m->path, subdir,
- (long long) time(NULL), mutt_rand64(), NONULL(ShortHostname), suffix);
+ snprintf(path, sizeof(path), "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s",
+ mutt_b2s(m->pathbuf), 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, m->path, NULL);
+ header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), 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", m->path);
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
/* 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", m->path) < sizeof(path)) &&
+ if ((snprintf(path, sizeof(path), "%s/.mh_sequences", mutt_b2s(m->pathbuf)) < 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", m->path, msgno) < sizeof(path)) &&
+ if ((snprintf(path, sizeof(path), "%s/%d", mutt_b2s(m->pathbuf), 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, m->path) < 0)
+ if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0)
return false;
m->msg_count = 0;
mhs_free_sequences(&mhs);
- dirp = opendir(m->path);
+ dirp = opendir(mutt_b2s(m->pathbuf));
if (dirp)
{
while ((de = readdir(dirp)))
return 0;
}
- if (mkdir(m->path, S_IRWXU))
+ if (mkdir(mutt_b2s(m->pathbuf), S_IRWXU))
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", m->path);
+ snprintf(tmp, sizeof(tmp), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
const int i = creat(tmp, S_IRWXU);
if (i == -1)
{
mutt_perror(tmp);
- rmdir(m->path);
+ rmdir(mutt_b2s(m->pathbuf));
return -1;
}
close(i);
if (!C_CheckNew)
return 0;
- mutt_str_strfcpy(buf, m->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
if (stat(buf, &st) == -1)
return -1;
/* create .mh_sequences when there isn't one. */
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", m->path);
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
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, m->path) < 0)
+ if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0)
return -1;
mh_update_maildir(md, &mhs);
mhs_free_sequences(&mhs);
return mdata->mh_umask;
struct stat st;
- if (stat(m->path, &st))
+ if (stat(mutt_b2s(m->pathbuf), &st))
{
- mutt_debug(LL_DEBUG1, "stat failed on %s\n", m->path);
+ mutt_debug(LL_DEBUG1, "stat failed on %s\n", mutt_b2s(m->pathbuf));
return 077;
}
mode_t omask = umask(mh_umask(m));
while (true)
{
- snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, m->path,
+ snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mutt_b2s(m->pathbuf),
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", m->path);
+ snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
FILE *fp_old = fopen(sequences, "r");
if (fp_old)
{
if (m->magic == MUTT_MAILDIR)
{
- snprintf(buf, sizeof(buf), "%s/%s", m->path, "cur");
+ snprintf(buf, sizeof(buf), "%s/%s", mutt_b2s(m->pathbuf), "cur");
if (stat(buf, &st) == 0)
mutt_file_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME);
- snprintf(buf, sizeof(buf), "%s/%s", m->path, "new");
+ snprintf(buf, sizeof(buf), "%s/%s", mutt_b2s(m->pathbuf), "new");
}
else
{
- snprintf(buf, sizeof(buf), "%s/.mh_sequences", m->path);
+ snprintf(buf, sizeof(buf), "%s/.mh_sequences", mutt_b2s(m->pathbuf));
if (stat(buf, &st) == 0)
mutt_file_get_stat_timespec(&mdata->mtime_cur, &st, MUTT_STAT_MTIME);
- mutt_str_strfcpy(buf, m->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
}
if (stat(buf, &st) == 0)
if (subdir)
{
- mutt_buffer_printf(buf, "%s/%s", m->path, subdir);
+ mutt_buffer_printf(buf, "%s/%s", mutt_b2s(m->pathbuf), subdir);
is_old = C_MarkOld ? (mutt_str_strcmp("cur", subdir) == 0) : false;
}
else
- mutt_buffer_strcpy(buf, m->path);
+ mutt_buffer_strcpy(buf, mutt_b2s(m->pathbuf));
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", m->path);
+ mutt_debug(LL_DEBUG3, "maildir: sorting %s into natural order\n", mutt_b2s(m->pathbuf));
*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, m->path, NULL);
+ header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), 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", m->path);
+ mutt_debug(LL_DEBUG3, "maildir: need to sort %s by inode\n", mutt_b2s(m->pathbuf));
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", m->path, p->email->path);
+ snprintf(fn, sizeof(fn), "%s/%s", mutt_b2s(m->pathbuf), p->email->path);
}
- snprintf(fn, sizeof(fn), "%s/%s", m->path, p->email->path);
+ snprintf(fn, sizeof(fn), "%s/%s", mutt_b2s(m->pathbuf), p->email->path);
#ifdef USE_HCACHE
struct stat lastchanged = { 0 };
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Scanning %s..."), mutt_b2s(m->pathbuf));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0);
}
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf));
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, m->path) < 0)
+ if (mh_read_sequences(&mhs, mutt_b2s(m->pathbuf)) < 0)
{
maildir_free_maildir(&md);
return -1;
struct Email *cur = m->emails[msgno];
char path[PATH_MAX];
- snprintf(path, sizeof(path), "%s/%s", m->path, cur->path);
+ snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), cur->path);
msg->fp = fopen(path, "r");
if (!msg->fp && (errno == ENOENT) && is_maildir)
- msg->fp = maildir_open_find_message(m->path, cur->path, NULL);
+ msg->fp = maildir_open_find_message(mutt_b2s(m->pathbuf), cur->path, NULL);
if (!msg->fp)
{
return -1;
}
- DIR *dirp = opendir(m->path);
+ DIR *dirp = opendir(mutt_b2s(m->pathbuf));
if (!dirp)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
{
hi++;
snprintf(tmp, sizeof(tmp), "%u", hi);
- snprintf(path, sizeof(path), "%s/%s", m->path, tmp);
+ snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), tmp);
if (mutt_file_safe_rename(msg->path, path) == 0)
{
if (e)
}
else if (errno != EEXIST)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
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", m->path, mutt_b2s(path));
+ mutt_buffer_printf(full, "%s/%s", mutt_b2s(m->pathbuf), mutt_b2s(path));
mutt_debug(LL_DEBUG2, "renaming %s to %s\n", msg->path, mutt_b2s(full));
}
else if (errno != EEXIST)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
rc = -1;
goto cleanup;
}
{
char oldpath[PATH_MAX];
char partpath[PATH_MAX];
- snprintf(oldpath, sizeof(oldpath), "%s/%s", m->path, e->path);
+ snprintf(oldpath, sizeof(oldpath), "%s/%s", mutt_b2s(m->pathbuf), 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", m->path, e->path);
+ snprintf(newpath, sizeof(newpath), "%s/%s", mutt_b2s(m->pathbuf), 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", m->path, e->path);
+ snprintf(path, sizeof(path), "%s/%s", mutt_b2s(m->pathbuf), 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", m->path, e->path);
+ snprintf(tmp, sizeof(tmp), "%s/,%s", mutt_b2s(m->pathbuf), e->path);
unlink(tmp);
rename(path, tmp);
}
#ifdef USE_HCACHE
if ((m->magic == MUTT_MAILDIR) || (m->magic == MUTT_MH))
- hc = mutt_hcache_open(C_HeaderCache, m->path, NULL);
+ hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
#endif
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf));
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, m->path, NULL);
+ header_cache_t *hc = mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), 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(m->path, &sb) == -1)
+ if (stat(mutt_b2s(m->pathbuf), &sb) == -1)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
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..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf));
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(m->path, &sb) == -1)
+ if (stat(mutt_b2s(m->pathbuf), &sb) == -1)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
mutt_file_get_stat_timespec(&adata->atime, &sb, MUTT_STAT_ATIME);
if (!m->readonly)
- m->readonly = access(m->path, W_OK) ? true : false;
+ m->readonly = access(mutt_b2s(m->pathbuf), W_OK) ? true : false;
if (!m->quiet)
{
char msgbuf[256];
- snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Reading %s..."), mutt_b2s(m->pathbuf));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_ReadInc, 0);
}
case MUTT_MMDF:
cmp_headers = mutt_email_cmp_strict;
mutt_file_fclose(&adata->fp);
- adata->fp = mutt_file_fopen(m->path, "r");
+ adata->fp = mutt_file_fopen(mutt_b2s(m->pathbuf), "r");
if (!adata->fp)
rc = -1;
else if (m->magic == MUTT_MBOX)
if (!st)
{
- if (stat(m->path, &st2) < 0)
+ if (stat(mutt_b2s(m->pathbuf), &st2) < 0)
return;
st = &st2;
}
utimebuf.actime = utimebuf.modtime - 1;
}
- utime(m->path, &utimebuf);
+ utime(mutt_b2s(m->pathbuf), &utimebuf);
}
/**
if (!np)
return NULL;
- if (mutt_str_strcmp(np->mailbox->path, path) != 0)
+ if (mutt_str_strcmp(mutt_b2s(np->mailbox->pathbuf), path) != 0)
return NULL;
return a;
if (!adata)
return -1;
- adata->fp = fopen(m->path, "r+");
+ adata->fp = fopen(mutt_b2s(m->pathbuf), "r+");
if (!adata->fp)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
mutt_sig_block();
if (!adata)
return -1;
- adata->fp = mutt_file_fopen(m->path, (flags & MUTT_NEWFOLDER) ? "w" : "a");
+ adata->fp = mutt_file_fopen(mutt_b2s(m->pathbuf), (flags & MUTT_NEWFOLDER) ? "w" : "a");
if (!adata->fp)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
if (mbox_lock_mailbox(m, true, true) != false)
{
- mutt_error(_("Couldn't lock %s"), m->path);
+ mutt_error(_("Couldn't lock %s"), mutt_b2s(m->pathbuf));
mutt_file_fclose(&adata->fp);
return -1;
}
bool unlock = false;
bool modified = false;
- if (stat(m->path, &st) == 0)
+ if (stat(mutt_b2s(m->pathbuf), &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(m->path, "r+", adata->fp);
+ adata->fp = freopen(mutt_b2s(m->pathbuf), "r+", adata->fp);
if (!adata->fp)
{
mx_fastclose_mailbox(m);
if (!m->quiet)
{
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count);
}
fp = NULL;
/* Save the state of this folder. */
- if (stat(m->path, &statbuf) == -1)
+ if (stat(mutt_b2s(m->pathbuf), &statbuf) == -1)
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
unlink(tempfile);
goto bail;
}
mbox_reset_atime(m, &statbuf);
/* reopen the mailbox in read-only mode */
- adata->fp = fopen(m->path, "r");
+ adata->fp = fopen(mutt_b2s(m->pathbuf), "r");
if (!adata->fp)
{
unlink(tempfile);
if (C_CheckMboxSize)
{
- struct Mailbox *tmp = mutt_find_mailbox(m->path);
+ struct Mailbox *tmp = mutt_find_mailbox(mutt_b2s(m->pathbuf));
if (tmp && !tmp->has_new)
mutt_update_mailbox(tmp);
}
FREE(&new_offset);
FREE(&old_offset);
- adata->fp = freopen(m->path, "r", adata->fp);
+ adata->fp = freopen(mutt_b2s(m->pathbuf), "r", adata->fp);
if (!adata->fp)
{
mutt_error(_("Could not reopen mailbox"));
mutt_file_fclose(&adata->fp);
/* fix up the times so mailbox won't get confused */
- if (m->peekonly && (m->path[0] != '\0') &&
+ if (m->peekonly && mutt_buffer_is_empty(m->pathbuf) &&
(mutt_file_timespec_compare(&m->mtime, &adata->atime) > 0))
{
#ifdef HAVE_UTIMENSAT
struct utimbuf ut;
ut.actime = adata->atime.tv_sec;
ut.modtime = m->mtime.tv_sec;
- utime(m->path, &ut);
+ utime(mutt_b2s(m->pathbuf), &ut);
#endif
}
static int mbox_mbox_check_stats(struct Mailbox *m, int flags)
{
struct stat sb = { 0 };
- if (stat(m->path, &sb) != 0)
+ if (stat(mutt_b2s(m->pathbuf), &sb) != 0)
return -1;
bool new_or_changed;
m->append = true;
if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR))
{
- m->magic = mx_path_probe(m->path, NULL);
+ m->magic = mx_path_probe(mutt_b2s(m->pathbuf), NULL);
if (m->magic == MUTT_UNKNOWN)
{
}
else
{
- mutt_error(_("%s is not a mailbox"), m->path);
+ mutt_error(_("%s is not a mailbox"), mutt_b2s(m->pathbuf));
return -1;
}
}
if (m->magic == MUTT_MAILBOX_ERROR)
{
- if (stat(m->path, &sb) == -1)
+ if (stat(mutt_b2s(m->pathbuf), &sb) == -1)
{
if (errno == ENOENT)
{
}
else
{
- mutt_perror(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
return -1;
}
}
if (m->magic == MUTT_UNKNOWN)
{
- m->magic = mx_path_probe(m->path, NULL);
+ m->magic = mx_path_probe(mutt_b2s(m->pathbuf), 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(m->path);
+ mutt_perror(mutt_b2s(m->pathbuf));
else if ((m->magic == MUTT_UNKNOWN) || !m->mx_ops)
- mutt_error(_("%s is not a mailbox"), m->path);
+ mutt_error(_("%s is not a mailbox"), mutt_b2s(m->pathbuf));
mx_fastclose_mailbox(m);
ctx_free(&ctx);
OptForceRefresh = true;
if (!m->quiet)
- mutt_message(_("Reading %s..."), m->path);
+ mutt_message(_("Reading %s..."), mutt_b2s(m->pathbuf));
int rc = m->mx_ops->mbox_open(ctx->mailbox);
m->opened++;
if (!m->quiet)
mutt_clear_error();
if (rc == -2)
- mutt_error(_("Reading from %s interrupted..."), m->path);
+ mutt_error(_("Reading from %s interrupted..."), mutt_b2s(m->pathbuf));
}
else
{
if (!m->quiet)
{
/* L10N: Displayed before/as a mailbox is being synced */
- mutt_message(_("Writing %s..."), m->path);
+ mutt_message(_("Writing %s..."), mutt_b2s(m->pathbuf));
}
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"), m->path);
+ mutt_error(_("Unable to write %s"), mutt_b2s(m->pathbuf));
}
return rc;
return -1;
}
- if ((lstat(m->path, &stc) == 0) && (stc.st_ino == st.st_ino) &&
+ if ((lstat(mutt_b2s(m->pathbuf), &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, m->path);
+ char *p = mutt_find_hook(MUTT_MBOX_HOOK, mutt_b2s(m->pathbuf));
if (p)
{
is_spool = true;
else
{
mutt_str_strfcpy(mbox, C_Mbox, sizeof(mbox));
- is_spool = mutt_is_spool(m->path) && !mutt_is_spool(mbox);
+ is_spool = mutt_is_spool(mutt_b2s(m->pathbuf)) && !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(m->path, C_Trash) != 0))
+ if (purge && (m->msg_deleted != 0) &&
+ (mutt_str_strcmp(mutt_b2s(m->pathbuf), 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(m->path) && !C_SaveEmpty)
+ !mutt_is_spool(mutt_b2s(m->pathbuf)) && !C_SaveEmpty)
{
- mutt_file_unlink_empty(m->path);
+ mutt_file_unlink_empty(mutt_b2s(m->pathbuf));
}
#ifdef USE_SIDEBAR
msgcount = m->msg_count;
deleted = m->msg_deleted;
- if (purge && (m->msg_deleted != 0) && (mutt_str_strcmp(m->path, C_Trash) != 0))
+ if (purge && (m->msg_deleted != 0) &&
+ (mutt_str_strcmp(mutt_b2s(m->pathbuf), 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(m->path) && !C_SaveEmpty)
+ !mutt_is_spool(mutt_b2s(m->pathbuf)) && !C_SaveEmpty)
{
- unlink(m->path);
+ unlink(mutt_b2s(m->pathbuf));
mx_fastclose_mailbox(m);
return 0;
}
if (m->realpath)
mutt_str_strfcpy(buf, m->realpath, sizeof(buf));
else
- mutt_str_strfcpy(buf, m->path, sizeof(buf));
+ mutt_str_strfcpy(buf, mutt_b2s(m->pathbuf), sizeof(buf));
int rc = mx_path_canon(buf, sizeof(buf), folder, &m->magic);
if (rc >= 0)
{
m->mx_ops = mx_get_ops(m->magic);
- mutt_str_strfcpy(m->path, m->realpath, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, m->realpath);
}
return rc;
m = mailbox_new();
m->flags = MB_HIDDEN;
- mutt_str_strfcpy(m->path, path, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, path);
mx_path_canon2(m, C_Folder);
return m;
void *hc = NULL;
anum_t first, last, count = 0;
- struct Url *url = url_parse(m->path);
+ struct Url *url = url_parse(mutt_b2s(m->pathbuf));
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"), m->path);
+ mutt_error(_("%s is an invalid newsgroup specification"), mutt_b2s(m->pathbuf));
return -1;
}
static header_cache_t *nm_hcache_open(struct Mailbox *m)
{
#ifdef USE_HCACHE
- return mutt_hcache_open(C_HeaderCache, m->path, NULL);
+ return mutt_hcache_open(C_HeaderCache, mutt_b2s(m->pathbuf), NULL);
#else
return NULL;
#endif
if (m->mdata)
return 0;
- m->mdata = nm_mdata_new(m->path);
+ m->mdata = nm_mdata_new(mutt_b2s(m->pathbuf));
if (!m->mdata)
return -1;
int limit = C_NmDbLimit;
mutt_debug(LL_DEBUG1, "nm: count\n");
- url = url_parse(m->path);
+ url = url_parse(mutt_b2s(m->pathbuf));
if (!url)
{
- mutt_error(_("failed to parse notmuch uri: %s"), m->path);
+ mutt_error(_("failed to parse notmuch uri: %s"), mutt_b2s(m->pathbuf));
goto done;
}
if ((np->mailbox->magic == MUTT_NOTMUCH) && np->mailbox->desc &&
(strcmp(desc, np->mailbox->desc) == 0))
{
- mutt_str_strfcpy(buf, np->mailbox->path, buflen);
+ mutt_str_strfcpy(buf, mutt_b2s(np->mailbox->pathbuf), buflen);
buf[buflen - 1] = '\0';
return 0;
}
int rc = 0;
struct Progress progress;
- char *uri = mutt_str_strdup(m->path);
+ char *uri = mutt_str_strdup(mutt_b2s(m->pathbuf));
bool changed = false;
char msgbuf[PATH_MAX + 64];
if (!m->quiet)
{
/* all is in this function so we don't use data->progress here */
- snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), m->path);
+ snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), mutt_b2s(m->pathbuf));
mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, C_WriteInc, m->msg_count);
}
else
email_get_fullpath(e, old, sizeof(old));
- mutt_str_strfcpy(m->path, edata->folder, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, edata->folder);
m->magic = edata->magic;
rc = mh_sync_mailbox_message(m, i, h);
- mutt_str_strfcpy(m->path, uri, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, uri);
m->magic = MUTT_NOTMUCH;
if (rc)
FREE(&edata->oldpath);
}
- mutt_str_strfcpy(m->path, uri, sizeof(m->path));
+ mutt_buffer_strcpy(m->pathbuf, uri);
m->magic = MUTT_NOTMUCH;
nm_db_release(m);
int check = mx_mbox_check(Context->mailbox, &index_hint);
if (check < 0)
{
- if (!Context->mailbox || (Context->mailbox->path[0] == '\0'))
+ if (!Context->mailbox || mutt_buffer_is_empty(Context->mailbox->pathbuf))
{
/* fatal error occurred */
ctx_free(&Context);
}
else
{
- char *escaped_folder = mutt_path_escape(Context->mailbox->path);
+ char *escaped_folder = mutt_path_escape(mutt_b2s(Context->mailbox->pathbuf));
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, m->path);
+ header_cache_t *hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf));
#endif
time(&adata->check_time);
a->adata = adata;
a->free_adata = pop_adata_free;
- struct Url *url = url_parse(m->path);
+ struct Url *url = url_parse(mutt_b2s(m->pathbuf));
if (url)
{
mutt_str_strfcpy(adata->conn_account.user, url->user,
struct ConnAccount acct = { { 0 } };
struct Url url;
- if (pop_parse_path(m->path, &acct))
+ if (pop_parse_path(mutt_b2s(m->pathbuf), &acct))
{
- mutt_error(_("%s is an invalid POP path"), m->path);
+ mutt_error(_("%s is an invalid POP path"), mutt_b2s(m->pathbuf));
return -1;
}
url.path = NULL;
url_tostring(&url, buf, sizeof(buf), 0);
- mutt_str_strfcpy(m->path, buf, sizeof(m->path));
- mutt_str_replace(&m->realpath, m->path);
+ mutt_buffer_strcpy(m->pathbuf, buf);
+ mutt_str_replace(&m->realpath, mutt_b2s(m->pathbuf));
struct PopAccountData *adata = m->account->adata;
if (!adata)
MUTT_PROGRESS_MSG, C_WriteInc, num_deleted);
#ifdef USE_HCACHE
- hc = pop_hcache_open(adata, m->path);
+ hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf));
#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, m->path);
+ header_cache_t *hc = pop_hcache_open(adata, mutt_b2s(m->pathbuf));
rc = mutt_hcache_store(hc, edata->uid, strlen(edata->uid), e, 0);
mutt_hcache_close(hc);
#endif
* mutt_expando_format to do the actual work. mutt_expando_format will callback to
* us using sidebar_format_str() for the sidebar specific formatting characters.
*/
-static void make_sidebar_entry(char *buf, size_t buflen, int width, char *box,
- struct SbEntry *sbe)
+static void make_sidebar_entry(char *buf, size_t buflen, int width,
+ const char *box, struct SbEntry *sbe)
{
if (!buf || !box || !sbe)
return;
{
case SORT_COUNT:
if (m2->msg_count == m1->msg_count)
- rc = mutt_str_strcoll(m1->path, m2->path);
+ rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
else
rc = (m2->msg_count - m1->msg_count);
break;
case SORT_UNREAD:
if (m2->msg_unread == m1->msg_unread)
- rc = mutt_str_strcoll(m1->path, m2->path);
+ rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
else
rc = (m2->msg_unread - m1->msg_unread);
break;
break;
case SORT_FLAGGED:
if (m2->msg_flagged == m1->msg_flagged)
- rc = mutt_str_strcoll(m1->path, m2->path);
+ rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
else
rc = (m2->msg_flagged - m1->msg_flagged);
break;
case SORT_PATH:
{
- rc = mutt_inbox_cmp(m1->path, m2->path);
+ rc = mutt_inbox_cmp(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
if (rc == 0)
- rc = mutt_str_strcoll(m1->path, m2->path);
+ rc = mutt_str_strcoll(mutt_b2s(m1->pathbuf), mutt_b2s(m2->pathbuf));
break;
}
}
continue;
}
- if (mutt_list_find(&SidebarWhitelist, sbe->mailbox->path) ||
+ if (mutt_list_find(&SidebarWhitelist, mutt_b2s(sbe->mailbox->pathbuf)) ||
mutt_list_find(&SidebarWhitelist, sbe->mailbox->desc))
{
/* 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(m->path, C_Spoolfile) == 0))
+ (mutt_str_strcmp(mutt_b2s(m->pathbuf), 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_str_strlen(m->path) > maildirlen) &&
- (mutt_str_strncmp(C_Folder, m->path, maildirlen) == 0) &&
- C_SidebarDelimChars && strchr(C_SidebarDelimChars, m->path[maildirlen]))
+ 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]))
{
maildir_is_prefix = true;
}
/* calculate depth of current folder and generate its display name with indented spaces */
int sidebar_folder_depth = 0;
- char *sidebar_folder_name = NULL;
+ const char *sidebar_folder_name;
+ struct Buffer *short_folder_name = NULL;
if (C_SidebarShortPath)
{
/* disregard a trailing separator, so strlen() - 2 */
- sidebar_folder_name = m->path;
+ sidebar_folder_name = mutt_b2s(m->pathbuf);
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 = m->path + maildir_is_prefix * (maildirlen + 1);
+ sidebar_folder_name = mutt_b2s(m->pathbuf) + 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 = m->path + maildir_is_prefix * (maildirlen + 1);
+ sidebar_folder_name = mutt_b2s(m->pathbuf) + maildir_is_prefix * (maildirlen + 1);
if (m->desc)
{
else if (maildir_is_prefix && C_SidebarFolderIndent)
{
int lastsep = 0;
- const char *tmp_folder_name = m->path + maildirlen + 1;
+ const char *tmp_folder_name = mutt_b2s(m->pathbuf) + maildirlen + 1;
int tmplen = (int) mutt_str_strlen(tmp_folder_name) - 1;
for (int i = 0; i < tmplen; i++)
{
{
if (C_SidebarShortPath)
tmp_folder_name += lastsep; /* basename */
- int sfn_len = mutt_str_strlen(tmp_folder_name) +
- sidebar_folder_depth * mutt_str_strlen(C_SidebarIndentString) + 1;
- sidebar_folder_name = mutt_mem_malloc(sfn_len);
- sidebar_folder_name[0] = '\0';
+ short_folder_name = mutt_buffer_pool_get();
for (int i = 0; i < sidebar_folder_depth; i++)
- mutt_str_strcat(sidebar_folder_name, sfn_len, NONULL(C_SidebarIndentString));
- mutt_str_strcat(sidebar_folder_name, sfn_len, tmp_folder_name);
+ mutt_buffer_addstr(short_folder_name, NONULL(C_SidebarIndentString));
+ mutt_buffer_addstr(short_folder_name, tmp_folder_name);
+ sidebar_folder_name = mutt_b2s(short_folder_name);
}
}
char str[256];
make_sidebar_entry(str, sizeof(str), w, sidebar_folder_name, entry);
printw("%s", str);
- if (sidebar_folder_depth > 0)
- FREE(&sidebar_folder_name);
+ mutt_buffer_pool_release(&short_folder_name);
row++;
}
{
mutt_str_strfcpy(tmp, m->desc, sizeof(tmp));
}
- else if (m && (m->path[0] != '\0'))
+ else if (m && mutt_buffer_is_empty(m->pathbuf))
{
- mutt_str_strfcpy(tmp, m->path, sizeof(tmp));
+ mutt_str_strfcpy(tmp, mutt_b2s(m->pathbuf), sizeof(tmp));
mutt_pretty_mailbox(tmp, sizeof(tmp));
}
else