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