Skip to content

Commit

Permalink
lib: Added o_stream_nsend_istream()
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and GitLab committed May 18, 2016
1 parent 6adf683 commit b90fb7f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib/ostream.c
Expand Up @@ -374,6 +374,27 @@ int o_stream_send_istream(struct ostream *outstream, struct istream *instream)
return ret;
}

void o_stream_nsend_istream(struct ostream *outstream, struct istream *instream)
{
switch (o_stream_send_istream(outstream, instream)) {
case 1:
break;
case 0:
outstream->real_stream->noverflow = TRUE;
break;
default:
if (outstream->stream_errno != 0)
break;
i_assert(instream->stream_errno != 0);
outstream->stream_errno = instream->stream_errno;
io_stream_set_error(&outstream->real_stream->iostream,
"nsend-istream: read(%s) failed: %s",
i_stream_get_name(instream),
o_stream_get_name(outstream));
}
outstream->real_stream->last_errors_not_checked = TRUE;
}

int o_stream_pwrite(struct ostream *stream, const void *data, size_t size,
uoff_t offset)
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib/ostream.h
Expand Up @@ -161,6 +161,10 @@ void o_stream_set_no_error_handling(struct ostream *stream, bool set);
descriptor, even if the source and destination overlaps. If the file must
be grown, you have to do it manually before calling this function. */
int o_stream_send_istream(struct ostream *outstream, struct istream *instream);
/* Same as o_stream_send_istream(), but assume that reads and writes will
succeed. If not, o_stream_nfinish() will fail with the correct error
message (even istream's). */
void o_stream_nsend_istream(struct ostream *outstream, struct istream *instream);

/* Write data to specified offset. Returns 0 if successful, -1 if error. */
int o_stream_pwrite(struct ostream *stream, const void *data, size_t size,
Expand Down

0 comments on commit b90fb7f

Please sign in to comment.