1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 04:21:16 +02:00

* Simplify communication with the hook a bit (don't use file

descriptors 3/4, just use stdin/stderr).
This commit is contained in:
Eelco Dolstra 2009-03-28 19:29:55 +00:00
parent 7fb548aa26
commit 3a2bbe7f8a
6 changed files with 68 additions and 117 deletions

View file

@ -229,6 +229,33 @@ void writeFile(const Path & path, const string & s)
}
string readLine(int fd)
{
string s;
while (1) {
checkInterrupt();
char ch;
ssize_t rd = read(fd, &ch, 1);
if (rd == -1) {
if (errno != EINTR)
throw SysError("reading a line");
} else if (rd == 0)
throw Error("unexpected EOF reading a line");
else {
if (ch == '\n') return s;
s += ch;
}
}
}
void writeLine(int fd, string s)
{
s += '\n';
writeFull(fd, (const unsigned char *) s.c_str(), s.size());
}
static void _computePathSize(const Path & path,
unsigned long long & bytes, unsigned long long & blocks)
{