From: Kevin McCarthy Date: Sun, 7 Oct 2018 22:18:34 +0000 (-0700) Subject: Convert buffy_maildir_check_dir to use BUFFER. X-Git-Tag: mutt-1-11-rel~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90a53062475785f151d0b6d5e284bd1bda445796;p=mutt Convert buffy_maildir_check_dir to use BUFFER. --- 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; }