diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-20 21:11:43 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-20 21:11:43 +0000 |
commit | 7984cfc7c18c85c5db42c5c7d57927b12c846ce0 (patch) | |
tree | a728a7500892e4de089c090538cb8fd34e4a1ffa /src/test.cc | |
parent | 667a6afb9dabcb3e5c851b910705b7eb1c87c9b6 (diff) |
* Argh, another short-write problem. Added wrappers around
read()/write() to fix this once and for all.
Diffstat (limited to 'src/test.cc')
-rw-r--r-- | src/test.cc | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/test.cc b/src/test.cc index fa7c93820..5c7559af6 100644 --- a/src/test.cc +++ b/src/test.cc @@ -37,21 +37,16 @@ struct MySink : DumpSink virtual void operator () (const unsigned char * data, unsigned int len) { /* Don't use cout, it's slow as hell! */ - if (write(STDOUT_FILENO, (char *) data, len) != (ssize_t) len) - throw SysError("writing to stdout"); + writeFull(STDOUT_FILENO, data, len); } }; struct MySource : RestoreSource { - virtual void operator () (const unsigned char * data, unsigned int len) + virtual void operator () (unsigned char * data, unsigned int len) { - ssize_t res = read(STDIN_FILENO, (char *) data, len); - if (res == -1) - throw SysError("reading from stdin"); - if (res != (ssize_t) len) - throw Error("not enough data available on stdin"); + readFull(STDIN_FILENO, data, len); } }; |