write_or_die.con commit Added mark store/find to fast-import. (d839716)
   1#include "cache.h"
   2
   3void write_or_die(int fd, const void *buf, size_t count)
   4{
   5        const char *p = buf;
   6        ssize_t written;
   7
   8        while (count > 0) {
   9                written = xwrite(fd, p, count);
  10                if (written == 0)
  11                        die("disk full?");
  12                else if (written < 0) {
  13                        if (errno == EPIPE)
  14                                exit(0);
  15                        die("write error (%s)", strerror(errno));
  16                }
  17                count -= written;
  18                p += written;
  19        }
  20}