Implementation of create interface.
Both the external and internal Dump managers define "Create"
interfaces. This commit implements these.
Change-Id: If857ec6ea7267fd72e9b420e6b44fa68b6abab66
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/dump_utils.hpp b/dump_utils.hpp
new file mode 100644
index 0000000..a71458c
--- /dev/null
+++ b/dump_utils.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+namespace phosphor
+{
+namespace dump
+{
+
+/** @struct CustomFd
+ *
+ * RAII wrapper for file descriptor.
+ */
+struct CustomFd
+{
+ private:
+ /** @brief File descriptor */
+ int fd = -1;
+
+ public:
+ CustomFd() = delete;
+ CustomFd(const CustomFd&) = delete;
+ CustomFd& operator=(const CustomFd&) = delete;
+ CustomFd(CustomFd&&) = delete;
+ CustomFd& operator=(CustomFd&&) = delete;
+
+ /** @brief Saves File descriptor and uses it to do file operation
+ *
+ * @param[in] fd - File descriptor
+ */
+ CustomFd(int fd) : fd(fd) {}
+
+ ~CustomFd()
+ {
+ if (fd >= 0)
+ {
+ close(fd);
+ }
+ }
+
+ int operator()() const
+ {
+ return fd;
+ }
+};
+
+} // namespace dump
+} // namespace phosphor