# HG changeset patch # User Timo Sirainen # Date 1112015203 -10800 # Node ID 904a268921afa4ef5880e2f93977201fb75f3a5f # Parent 889a584bd953a102b16a1419feae59b8aa2293d6 Added seekable variable to struct istream. diff -r 889a584bd953 -r 904a268921af src/lib-mail/istream-header-filter.c --- a/src/lib-mail/istream-header-filter.c Sun Mar 27 19:38:38 2005 +0300 +++ b/src/lib-mail/istream-header-filter.c Mon Mar 28 16:06:43 2005 +0300 @@ -310,5 +310,6 @@ mstream->istream.read = _read; mstream->istream.seek = _seek; + mstream->istream.istream.seekable = input->seekable; return _i_stream_create(&mstream->istream, pool, -1, 0); } diff -r 889a584bd953 -r 904a268921af src/lib/istream-data.c --- a/src/lib/istream-data.c Sun Mar 27 19:38:38 2005 +0300 +++ b/src/lib/istream-data.c Mon Mar 28 16:06:43 2005 +0300 @@ -50,5 +50,6 @@ stream->seek = _seek; stream->get_size = _get_size; + stream->istream.seekable = TRUE; return _i_stream_create(stream, pool, -1, 0); } diff -r 889a584bd953 -r 904a268921af src/lib/istream-file.c --- a/src/lib/istream-file.c Sun Mar 27 19:38:38 2005 +0300 +++ b/src/lib/istream-file.c Mon Mar 28 16:06:43 2005 +0300 @@ -160,7 +160,7 @@ { struct file_istream *fstream = (struct file_istream *) stream; - if (!fstream->file) { + if (!stream->istream.seekable) { if (v_offset < stream->istream.v_offset) { stream->istream.stream_errno = ESPIPE; return; @@ -203,8 +203,10 @@ fstream->istream.get_size = _get_size; /* get size of fd if it's a file */ - if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) + if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { fstream->file = TRUE; + fstream->istream.istream.seekable = TRUE; + } return _i_stream_create(&fstream->istream, pool, fd, 0); } diff -r 889a584bd953 -r 904a268921af src/lib/istream-limit.c --- a/src/lib/istream-limit.c Sun Mar 27 19:38:38 2005 +0300 +++ b/src/lib/istream-limit.c Mon Mar 28 16:06:43 2005 +0300 @@ -122,6 +122,7 @@ lstream->istream.seek = _seek; lstream->istream.get_size = _get_size; + lstream->istream.istream.seekable = input->seekable; return _i_stream_create(&lstream->istream, pool, i_stream_get_fd(input), input->real_stream->abs_start_offset + v_start_offset); diff -r 889a584bd953 -r 904a268921af src/lib/istream-mmap.c --- a/src/lib/istream-mmap.c Sun Mar 27 19:38:38 2005 +0300 +++ b/src/lib/istream-mmap.c Mon Mar 28 16:06:43 2005 +0300 @@ -202,5 +202,6 @@ istream = _i_stream_create(&mstream->istream, pool, fd, start_offset); istream->mmaped = TRUE; + istream->seekable = TRUE; return istream; } diff -r 889a584bd953 -r 904a268921af src/lib/istream.h --- a/src/lib/istream.h Sun Mar 27 19:38:38 2005 +0300 +++ b/src/lib/istream.h Mon Mar 28 16:06:43 2005 +0300 @@ -7,6 +7,7 @@ int stream_errno; unsigned int mmaped:1; /* be careful when copying data */ unsigned int closed:1; + unsigned int seekable:1; /* we can seek() backwards */ unsigned int eof:1; /* read() has reached to end of file (but may still be data available in buffer) */