Break out DuplicatableFileHandle

Static analysis notes that writing non-trivial move constructors and
move operator= handlers is non trivial [1].  Funnily enough, we actually
already had bugs on this that were fixed in 06fc9be.

Simplify the code.

Tested: Redfish service validator passes.

[1] https://sonarcloud.io/project/issues?issues=AY9_HYiwKXKyw1ZFwgUG%2CAY9_HYiwKXKyw1ZFwgUF&id=edtanous_bmcweb&open=AY9_HYiwKXKyw1ZFwgUG

Change-Id: If96383d8c669ae9e5a8cc13304071b2dfe1ff2d2
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/include/duplicatable_file_handle.hpp b/include/duplicatable_file_handle.hpp
new file mode 100644
index 0000000..6d2514e
--- /dev/null
+++ b/include/duplicatable_file_handle.hpp
@@ -0,0 +1,27 @@
+#include <boost/beast/core/file_posix.hpp>
+
+struct DuplicatableFileHandle
+{
+    boost::beast::file_posix fileHandle;
+
+    DuplicatableFileHandle() = default;
+    DuplicatableFileHandle(DuplicatableFileHandle&&) noexcept = default;
+    // Overload copy constructor, because posix doesn't have dup(), but linux
+    // does
+    DuplicatableFileHandle(const DuplicatableFileHandle& other)
+    {
+        fileHandle.native_handle(dup(other.fileHandle.native_handle()));
+    }
+    DuplicatableFileHandle& operator=(const DuplicatableFileHandle& other)
+    {
+        if (this == &other)
+        {
+            return *this;
+        }
+        fileHandle.native_handle(dup(other.fileHandle.native_handle()));
+        return *this;
+    }
+    DuplicatableFileHandle&
+        operator=(DuplicatableFileHandle&& other) noexcept = default;
+    ~DuplicatableFileHandle() = default;
+};