diff options
author | Tor Andersson <tor@ghostscript.com> | 2004-11-25 10:42:53 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2004-11-25 10:42:53 +0100 |
commit | e8696b4046767fcbfc05056c13f919fdeff65158 (patch) | |
tree | ac03d0f565f8ad74818a9486cfbadc1d730c35ee /filter | |
parent | 6a2ce62be0518a6e5690d6a1d23527ede5a91150 (diff) | |
download | mupdf-e8696b4046767fcbfc05056c13f919fdeff65158.tar.xz |
join content streams
Diffstat (limited to 'filter')
-rw-r--r-- | filter/filew.c | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/filter/filew.c b/filter/filew.c index 1ac446fe..f83399a2 100644 --- a/filter/filew.c +++ b/filter/filew.c @@ -93,10 +93,13 @@ fz_write(fz_file *f, unsigned char *buf, int n) if (f->in->wp == f->in->ep) { - x = dowrite(f->in, f->fd); - if (x < 0) { - f->error = fz_throw("ioerror in write: %s", strerror(errno)); - return -1; + if (f->fd != -1) + { + x = dowrite(f->in, f->fd); + if (x < 0) { + f->error = fz_throw("ioerror in write: %s", strerror(errno)); + return -1; + } } if (f->in->rp > f->in->bp) @@ -134,10 +137,13 @@ fz_write(fz_file *f, unsigned char *buf, int n) else if (reason == fz_ioneedout) { - x = dowrite(f->out, f->fd); - if (x < 0) { - f->error = fz_throw("ioerror in write: %s", strerror(errno)); - return -1; + if (f->fd != -1) + { + x = dowrite(f->out, f->fd); + if (x < 0) { + f->error = fz_throw("ioerror in write: %s", strerror(errno)); + return -1; + } } if (f->out->rp > f->out->bp) @@ -150,12 +156,15 @@ fz_write(fz_file *f, unsigned char *buf, int n) else if (reason == fz_iodone) { - while (f->out->rp < f->out->wp) + if (f->fd != -1) { - x = dowrite(f->out, f->fd); - if (x < 0) { - f->error = fz_throw("ioerror in write: %s", strerror(errno)); - return -1; + while (f->out->rp < f->out->wp) + { + x = dowrite(f->out, f->fd); + if (x < 0) { + f->error = fz_throw("ioerror in write: %s", strerror(errno)); + return -1; + } } } break; @@ -184,12 +193,15 @@ fz_flush(fz_file *f) if (!f->filter) { - while (f->in->rp < f->in->wp) + if (f->fd != -1) { - n = dowrite(f->in, f->fd); - if (n < 0) { - f->error = fz_throw("ioerror in write: %s", strerror(errno)); - return -1; + while (f->in->rp < f->in->wp) + { + n = dowrite(f->in, f->fd); + if (n < 0) { + f->error = fz_throw("ioerror in write: %s", strerror(errno)); + return -1; + } } } return 0; @@ -206,10 +218,13 @@ fz_flush(fz_file *f) else if (reason == fz_ioneedout) { - n = dowrite(f->out, f->fd); - if (n < 0) { - f->error = fz_throw("ioerror in write: %s", strerror(errno)); - return -1; + if (f->fd != -1) + { + n = dowrite(f->out, f->fd); + if (n < 0) { + f->error = fz_throw("ioerror in write: %s", strerror(errno)); + return -1; + } } if (f->out->rp > f->out->bp) @@ -222,15 +237,19 @@ fz_flush(fz_file *f) else if (reason == fz_iodone) { - n = dowrite(f->out, f->fd); - if (n < 0) { - f->error = fz_throw("ioerror in write: %s", strerror(errno)); - return -1; + if (f->fd != -1) + { + n = dowrite(f->out, f->fd); + if (n < 0) { + f->error = fz_throw("ioerror in write: %s", strerror(errno)); + return -1; + } } break; } - else { + else + { f->error = reason; return -1; } |