aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r--src/libutil/serialise.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index 6450a9651..692144b75 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -52,7 +52,18 @@ FdSink::~FdSink()
void FdSink::writeUnbuffered(std::string_view data)
{
written += data.size();
- writeFull(fd, data);
+ try {
+ writeFull(fd, data);
+ } catch (SysError & e) {
+ _good = false;
+ throw;
+ }
+}
+
+
+bool FdSink::good()
+{
+ return _good;
}
@@ -117,13 +128,19 @@ size_t FdSource::readUnbuffered(char * data, size_t len)
checkInterrupt();
n = ::read(fd, data, len);
} while (n == -1 && errno == EINTR);
- if (n == -1) { throw SysError("reading from file"); }
- if (n == 0) { throw EndOfFile(std::string(*endOfFileError)); }
+ if (n == -1) { _good = false; throw SysError("reading from file"); }
+ if (n == 0) { _good = false; throw EndOfFile(std::string(*endOfFileError)); }
read += n;
return n;
}
+bool FdSource::good()
+{
+ return _good;
+}
+
+
size_t StringSource::read(char * data, size_t len)
{
if (pos == s.size()) throw EndOfFile("end of string reached");