diff options
author | Kevin McCarthy <kevin@8t8.us> | 2018-10-07 15:18:34 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2018-10-08 10:50:01 -0700 |
commit | 90a53062475785f151d0b6d5e284bd1bda445796 (patch) | |
tree | 1a3088e170736e0a58bc6462222bb38648a801c4 /buffy.c | |
parent | 3405aeeeec20e77a69518c3935beec576c4353a8 (diff) |
Convert buffy_maildir_check_dir to use BUFFER.
Diffstat (limited to 'buffy.c')
-rw-r--r-- | buffy.c | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -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; } |