Nix  2.93.0-dev
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
file-descriptor.hh
Go to the documentation of this file.
1#pragma once
3
6
7namespace nix {
8
9struct Sink;
10struct Source;
11
15std::string readLine(int fd);
16
20void writeLine(int fd, std::string s);
21
25std::string readFile(int fd);
26
31void readFull(int fd, char * buf, size_t count);
32void writeFull(int fd, std::string_view s, bool allowInterrupts = true);
33
37std::string drainFD(int fd, bool block = true, const size_t reserveSize=0);
38
39Generator<Bytes> drainFDSource(int fd, bool block = true);
40
42{
43 int fd;
44public:
46 explicit AutoCloseFD(int fd);
47 AutoCloseFD(const AutoCloseFD & fd) = delete;
50 AutoCloseFD& operator =(const AutoCloseFD & fd) = delete;
51 AutoCloseFD& operator =(AutoCloseFD&& fd) noexcept(false);
52 int get() const;
53 explicit operator bool() const;
54 int release();
55 void close();
56 void fsync();
57 void reset() { *this = {}; }
58};
59
60class Pipe
61{
62public:
63 AutoCloseFD readSide, writeSide;
64 void create();
65 void close();
66};
67
72void closeExtraFDs();
73
77void closeOnExec(int fd);
78
79MakeError(EndOfFile, Error);
80
81}
Definition file-descriptor.hh:42
Definition file-descriptor.hh:61
This file defines two main structs/classes used in nix error handling.