nixd
Loading...
Searching...
No Matches
nixd
lib
Support
AutoCloseFD.cpp
Go to the documentation of this file.
1
#include "
nixd/Support/AutoCloseFD.h
"
2
3
#include <unistd.h>
4
5
namespace
nixd::util
{
6
7
AutoCloseFD::~AutoCloseFD
() {
8
if
(FD != ReleasedFD) [[likely]]
9
close(FD);
10
}
11
12
AutoCloseFD::AutoCloseFD
(
AutoCloseFD
&&That) noexcept : FD(That.get()) {
13
That.release();
14
}
15
16
AutoCloseFD::FDTy
AutoCloseFD::get
()
const
{
return
FD; }
17
18
void
AutoCloseFD::release
() { FD = ReleasedFD; }
19
20
bool
AutoCloseFD::isReleased
(
FDTy
FD) {
return
FD == ReleasedFD; }
21
22
bool
AutoCloseFD::isReleased
()
const
{
return
isReleased
(FD); }
23
24
AutoCloseFD::AutoCloseFD
(
FDTy
FD) : FD(FD) {}
25
26
}
// namespace nixd::util
AutoCloseFD.h
nixd::util::AutoCloseFD
File Descriptor RAII wrapper.
Definition
AutoCloseFD.h:8
nixd::util::AutoCloseFD::AutoCloseFD
AutoCloseFD(FDTy FD)
Definition
AutoCloseFD.cpp:24
nixd::util::AutoCloseFD::~AutoCloseFD
~AutoCloseFD()
Definition
AutoCloseFD.cpp:7
nixd::util::AutoCloseFD::get
FDTy get() const
Definition
AutoCloseFD.cpp:16
nixd::util::AutoCloseFD::release
void release()
Definition
AutoCloseFD.cpp:18
nixd::util::AutoCloseFD::FDTy
int FDTy
Definition
AutoCloseFD.h:10
nixd::util::AutoCloseFD::isReleased
bool isReleased() const
Definition
AutoCloseFD.cpp:22
nixd::util
Definition
AutoCloseFD.h:5
Generated by
1.12.0