blob: 6d2514e53ae115bd3f8e2bad45a4132df32c259e [file] [log] [blame]
Ed Tanousf51d8632024-05-16 09:14:01 -07001#include <boost/beast/core/file_posix.hpp>
2
3struct DuplicatableFileHandle
4{
5 boost::beast::file_posix fileHandle;
6
7 DuplicatableFileHandle() = default;
8 DuplicatableFileHandle(DuplicatableFileHandle&&) noexcept = default;
9 // Overload copy constructor, because posix doesn't have dup(), but linux
10 // does
11 DuplicatableFileHandle(const DuplicatableFileHandle& other)
12 {
13 fileHandle.native_handle(dup(other.fileHandle.native_handle()));
14 }
15 DuplicatableFileHandle& operator=(const DuplicatableFileHandle& other)
16 {
17 if (this == &other)
18 {
19 return *this;
20 }
21 fileHandle.native_handle(dup(other.fileHandle.native_handle()));
22 return *this;
23 }
24 DuplicatableFileHandle&
25 operator=(DuplicatableFileHandle&& other) noexcept = default;
26 ~DuplicatableFileHandle() = default;
27};