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;
}
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)
{
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;
}
closedir (dirp);
+cleanup:
+ mutt_buffer_pool_release (&path);
+ mutt_buffer_pool_release (&msgpath);
+
return rc;
}