Mercurial > dovecot > core-2.2
changeset 3647:7af5162d934c HEAD
Added exact parameter to i_stream_stat()
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 Oct 2005 12:55:29 +0300 |
parents | f50496e14ac8 |
children | 2c19efe2ddb6 |
files | src/lib-mail/istream-header-filter.c src/lib-storage/index/mbox/istream-raw-mbox.c src/lib-storage/index/mbox/mbox-sync.c src/lib/istream-data.c src/lib/istream-file.c src/lib/istream-internal.h src/lib/istream-limit.c src/lib/istream-mmap.c src/lib/istream-seekable.c src/lib/istream.c src/lib/istream.h src/lib/ostream-file.c |
diffstat | 12 files changed, 30 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/istream-header-filter.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib-mail/istream-header-filter.c Sun Oct 09 12:55:29 2005 +0300 @@ -278,7 +278,8 @@ i_panic("istream-header-filter sync() not implemented"); } -static const struct stat *_stat(struct _istream *stream) +static const struct stat * +_stat(struct _istream *stream, int exact __attr_unused__) { /* return size and others as unknown */ return &stream->statbuf;
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Sun Oct 09 12:55:29 2005 +0300 @@ -302,11 +302,11 @@ rstream->istream.pos = 0; } -static const struct stat *_stat(struct _istream *stream) +static const struct stat *_stat(struct _istream *stream, int exact) { struct raw_mbox_istream *rstream = (struct raw_mbox_istream *)stream; - return i_stream_stat(rstream->input); + return i_stream_stat(rstream->input, exact); } struct istream *i_stream_create_raw_mbox(pool_t pool, struct istream *input)
--- a/src/lib-storage/index/mbox/mbox-sync.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Sun Oct 09 12:55:29 2005 +0300 @@ -914,7 +914,7 @@ if (seq1 == 0) { /* doesn't exist anymore, seek to end of file */ - st = i_stream_stat(sync_ctx->mbox->mbox_file_stream); + st = i_stream_stat(sync_ctx->mbox->mbox_file_stream, TRUE); if (st == NULL) { mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()"); @@ -1219,7 +1219,7 @@ /* make sure i_stream_stat() doesn't try to use cached file size */ i_stream_sync(sync_ctx->file_input); - st = i_stream_stat(sync_ctx->file_input); + st = i_stream_stat(sync_ctx->file_input, TRUE); if (st == NULL) { mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()"); return -1; @@ -1278,7 +1278,7 @@ i_assert(sync_ctx->write_fd != -1); /* copy trailer, then truncate the file */ - st = i_stream_stat(sync_ctx->file_input); + st = i_stream_stat(sync_ctx->file_input, TRUE); if (st == NULL) { mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()"); @@ -1321,7 +1321,7 @@ { const struct stat *st; - st = i_stream_stat(sync_ctx->file_input); + st = i_stream_stat(sync_ctx->file_input, FALSE); if (st == NULL) { mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()"); return -1; @@ -1409,7 +1409,7 @@ const struct stat *st; int ret, partial; - st = i_stream_stat(sync_ctx->file_input); + st = i_stream_stat(sync_ctx->file_input, FALSE); if (st == NULL) { mbox_set_syscall_error(sync_ctx->mbox, "i_stream_stat()"); @@ -1485,7 +1485,7 @@ if (mbox->mbox_file_stream != NULL && mbox->mbox_fd == -1) { /* read-only stream */ - st = i_stream_stat(mbox->mbox_file_stream); + st = i_stream_stat(mbox->mbox_file_stream, FALSE); if (st == NULL) { mbox_set_syscall_error(mbox, "i_stream_stat()"); return -1;
--- a/src/lib/istream-data.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream-data.c Sun Oct 09 12:55:29 2005 +0300 @@ -29,7 +29,8 @@ stream->istream.v_offset = v_offset; } -static const struct stat *_stat(struct _istream *stream) +static const struct stat * +_stat(struct _istream *stream, int exact __attr_unused__) { stream->statbuf.st_size = stream->pos; return &stream->statbuf;
--- a/src/lib/istream-file.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream-file.c Sun Oct 09 12:55:29 2005 +0300 @@ -206,7 +206,8 @@ return 0; } -static const struct stat *_stat(struct _istream *stream) +static const struct stat * +_stat(struct _istream *stream, int exact __attr_unused__) { struct file_istream *fstream = (struct file_istream *) stream;
--- a/src/lib/istream-internal.h Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream-internal.h Sun Oct 09 12:55:29 2005 +0300 @@ -14,7 +14,7 @@ ssize_t (*read)(struct _istream *stream); void (*seek)(struct _istream *stream, uoff_t v_offset, int mark); void (*sync)(struct _istream *stream); - const struct stat *(*stat)(struct _istream *stream); + const struct stat *(*stat)(struct _istream *stream, int exact); /* data: */ struct istream istream;
--- a/src/lib/istream-limit.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream-limit.c Sun Oct 09 12:55:29 2005 +0300 @@ -92,12 +92,12 @@ stream->skip = stream->pos = 0; } -static const struct stat *_stat(struct _istream *stream) +static const struct stat *_stat(struct _istream *stream, int exact) { struct limit_istream *lstream = (struct limit_istream *) stream; const struct stat *st; - st = i_stream_stat(lstream->input); + st = i_stream_stat(lstream->input, exact); if (st == NULL) return NULL;
--- a/src/lib/istream-mmap.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream-mmap.c Sun Oct 09 12:55:29 2005 +0300 @@ -185,7 +185,8 @@ return 0; } -static const struct stat *_stat(struct _istream *stream) +static const struct stat * +_stat(struct _istream *stream, int exact __attr_unused__) { struct mmap_istream *mstream = (struct mmap_istream *) stream;
--- a/src/lib/istream-seekable.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream-seekable.c Sun Oct 09 12:55:29 2005 +0300 @@ -263,7 +263,7 @@ stream->skip = stream->pos = 0; } -static const struct stat *_stat(struct _istream *stream) +static const struct stat *_stat(struct _istream *stream, int exact) { struct seekable_istream *sstream = (struct seekable_istream *)stream; uoff_t old_offset; @@ -283,7 +283,7 @@ } if (sstream->fd_input != NULL) - return i_stream_stat(sstream->fd_input); + return i_stream_stat(sstream->fd_input, exact); stream->statbuf.st_size = sstream->buffer->used; return &stream->statbuf;
--- a/src/lib/istream.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream.c Sun Oct 09 12:55:29 2005 +0300 @@ -110,14 +110,14 @@ _stream->sync(_stream); } -const struct stat *i_stream_stat(struct istream *stream) +const struct stat *i_stream_stat(struct istream *stream, int exact) { struct _istream *_stream = stream->real_stream; if (stream->closed) return NULL; - return _stream->stat(_stream); + return _stream->stat(_stream, exact); } int i_stream_have_bytes_left(struct istream *stream)
--- a/src/lib/istream.h Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/istream.h Sun Oct 09 12:55:29 2005 +0300 @@ -59,8 +59,12 @@ void i_stream_seek_mark(struct istream *stream, uoff_t v_offset); /* Returns struct stat, or NULL if error. As the underlying stream may not be a file, only some of the fields might be set, others would be zero. - st_size is always set, and if it's not known, it's -1. */ -const struct stat *i_stream_stat(struct istream *stream); + st_size is always set, and if it's not known, it's -1. + + If exact=FALSE, the stream may not return exactly correct values, but the + returned values can be compared to see if anything had changed (eg. in + compressed stream st_size could be compressed size) */ +const struct stat *i_stream_stat(struct istream *stream, int exact); /* Returns TRUE if there are any bytes left to be read or in buffer. */ int i_stream_have_bytes_left(struct istream *stream);
--- a/src/lib/ostream-file.c Fri Oct 07 13:43:28 2005 +0300 +++ b/src/lib/ostream-file.c Sun Oct 09 12:55:29 2005 +0300 @@ -674,7 +674,7 @@ off_t ret; int in_fd, overlapping; - st = i_stream_stat(instream); + st = i_stream_stat(instream, TRUE); if (st == NULL) { if (errno == EINVAL) i_error("_send_istream() / stat -> EINVAL"); outstream->ostream.stream_errno = instream->stream_errno;