Mercurial > dovecot > original-hg > dovecot-1.2
view src/lib-index/maildir/maildir-open.c @ 363:567e932cdc66 HEAD
Added autoclose_fd-flag for io_buffer_create_file() and
io_buffer_create_mmap().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 06 Oct 2002 06:09:36 +0300 |
parents | cf4d065f2f85 |
children | 60040a9d243f |
line wrap: on
line source
/* Copyright (C) 2002 Timo Sirainen */ #include "lib.h" #include "iobuffer.h" #include "maildir-index.h" #include "mail-index-data.h" #include "mail-index-util.h" #include <unistd.h> #include <fcntl.h> IOBuffer *maildir_open_mail(MailIndex *index, MailIndexRecord *rec) { const char *fname, *path; int fd; i_assert(index->lock_type != MAIL_LOCK_UNLOCK); /* check for inconsistency here, to avoid extra error messages */ if (index->inconsistent) return NULL; fname = index->lookup_field(index, rec, FIELD_TYPE_LOCATION); if (fname == NULL) { index_data_set_corrupted(index->data, "Missing location field " "for record %u", rec->uid); return NULL; } path = t_strconcat(index->dir, "/cur/", fname, NULL); fd = open(path, O_RDONLY); if (fd == -1) { index_set_error(index, "Error opening mail file %s: %m", path); return NULL; } return io_buffer_create_mmap(fd, default_pool, MAIL_MMAP_BLOCK_SIZE, 0, TRUE); }