Commit 90a53062 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Convert buffy_maildir_check_dir to use BUFFER.

parent 3405aeee
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment