summaryrefslogtreecommitdiffstats
path: root/buffy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2018-10-07 15:18:34 -0700
committerKevin McCarthy <kevin@8t8.us>2018-10-08 10:50:01 -0700
commit90a53062475785f151d0b6d5e284bd1bda445796 (patch)
tree1a3088e170736e0a58bc6462222bb38648a801c4 /buffy.c
parent3405aeeeec20e77a69518c3935beec576c4353a8 (diff)
Convert buffy_maildir_check_dir to use BUFFER.
Diffstat (limited to 'buffy.c')
-rw-r--r--buffy.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/buffy.c b/buffy.c
index 6d7fbe56..b231f0cd 100644
--- a/buffy.c
+++ b/buffy.c
@@ -349,22 +349,24 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
static int buffy_maildir_check_dir (BUFFY* mailbox, const char *dir_name, int check_new,
int check_stats)
{
- char path[_POSIX_PATH_MAX];
- char msgpath[_POSIX_PATH_MAX];
+ BUFFER *path = NULL;
+ BUFFER *msgpath = NULL;
DIR *dirp;
struct dirent *de;
char *p;
int rc = 0;
struct stat sb;
- snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir_name);
+ path = mutt_buffer_pool_get ();
+ msgpath = mutt_buffer_pool_get ();
+ mutt_buffer_printf (path, "%s/%s", mailbox->path, dir_name);
/* when $mail_check_recent is set, if the new/ directory hasn't been modified since
* the user last exited the mailbox, then we know there is no recent mail.
*/
if (check_new && option(OPTMAILCHECKRECENT))
{
- if (stat(path, &sb) == 0 &&
+ if (stat(mutt_b2s (path), &sb) == 0 &&
mutt_stat_timespec_compare (&sb, MUTT_STAT_MTIME, &mailbox->last_visited) < 0)
{
rc = 0;
@@ -373,12 +375,13 @@ static int buffy_maildir_check_dir (BUFFY* mailbox, const char *dir_name, int ch
}
if (! (check_new || check_stats))
- return rc;
+ goto cleanup;
- if ((dirp = opendir (path)) == NULL)
+ if ((dirp = opendir (mutt_b2s (path))) == NULL)
{
mailbox->magic = 0;
- return 0;
+ rc = 0;
+ goto cleanup;
}
while ((de = readdir (dirp)) != NULL)
@@ -404,9 +407,9 @@ static int buffy_maildir_check_dir (BUFFY* mailbox, const char *dir_name, int ch
{
if (option(OPTMAILCHECKRECENT))
{
- snprintf(msgpath, sizeof(msgpath), "%s/%s", path, de->d_name);
+ mutt_buffer_printf (msgpath, "%s/%s", mutt_b2s (path), de->d_name);
/* ensure this message was received since leaving this mailbox */
- if (stat(msgpath, &sb) == 0 &&
+ if (stat(mutt_b2s (msgpath), &sb) == 0 &&
(mutt_stat_timespec_compare (&sb, MUTT_STAT_CTIME, &mailbox->last_visited) <= 0))
continue;
}
@@ -421,6 +424,10 @@ static int buffy_maildir_check_dir (BUFFY* mailbox, const char *dir_name, int ch
closedir (dirp);
+cleanup:
+ mutt_buffer_pool_release (&path);
+ mutt_buffer_pool_release (&msgpath);
+
return rc;
}