about summary refs log tree commit diff
path: root/src/nix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-20T21·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-20T21·11+0000
commit7984cfc7c18c85c5db42c5c7d57927b12c846ce0 (patch)
treea728a7500892e4de089c090538cb8fd34e4a1ffa /src/nix.cc
parent667a6afb9dabcb3e5c851b910705b7eb1c87c9b6 (diff)
* Argh, another short-write problem. Added wrappers around
  read()/write() to fix this once and for all.

Diffstat (limited to 'src/nix.cc')
-rw-r--r--src/nix.cc17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/nix.cc b/src/nix.cc
index f5ca0b4d87..ad4e6a468a 100644
--- a/src/nix.cc
+++ b/src/nix.cc
@@ -215,12 +215,7 @@ struct StdoutSink : DumpSink
     virtual void operator ()
         (const unsigned char * data, unsigned int len)
     {
-        while (len) {
-            ssize_t res = write(STDOUT_FILENO, (char *) data, len);
-            if (res == -1) throw SysError("writing to stdout");
-            len -= res;
-            data += res;
-        }
+        writeFull(STDOUT_FILENO, data, len);
     }
 };
 
@@ -247,15 +242,9 @@ static void opDump(Strings opFlags, Strings opArgs)
 /* A source that read restore intput to stdin. */
 struct StdinSource : RestoreSource
 {
-    virtual void operator () (const unsigned char * data, unsigned int len)
+    virtual void operator () (unsigned char * data, unsigned int len)
     {
-        while (len) {
-            ssize_t res = read(STDIN_FILENO, (char *) data, len);
-            if (res == -1) throw SysError("reading from stdin");
-            if (res == 0) throw Error("unexpected end-of-file on stdin");
-            len -= res;
-            data += res;
-        }
+        readFull(STDIN_FILENO, data, len);
     }
 };