nixd
Loading...
Searching...
No Matches
AutoCloseFD.h
Go to the documentation of this file.
1#pragma once
2
3#include <cerrno>
4
5namespace nixd::util {
6
7/// \brief File Descriptor RAII wrapper
9public:
10 using FDTy = int;
11
12private:
13 static constexpr FDTy ReleasedFD = -EBADF;
14 FDTy FD;
15
16public:
17 AutoCloseFD(FDTy FD);
18 AutoCloseFD(const AutoCloseFD &) = delete;
19 AutoCloseFD(AutoCloseFD &&That) noexcept;
20
21 [[nodiscard]] bool isReleased() const;
22 static bool isReleased(FDTy FD);
23
25
26 [[nodiscard]] FDTy get() const;
27 void release();
28};
29
30} // namespace nixd::util
File Descriptor RAII wrapper.
Definition AutoCloseFD.h:8
AutoCloseFD(const AutoCloseFD &)=delete