1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors 3 #include <boost/beast/core/file_posix.hpp> 4 5 struct 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 }; 30