summaryrefslogtreecommitdiffstats
path: root/utility.hpp
diff options
context:
space:
mode:
authorBrandon Wyman <bjwyman@gmail.com>2017-03-31 18:13:21 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-19 16:19:06 +0000
commitfef0295a8d87754e491dcf133ea927b5c4d56303 (patch)
tree625df8225e8d9681ff1b5f9afb77104c9e899946 /utility.hpp
parentaf5d4c5ec0e07ba7a87ddff3f2066d9b3cbb52f8 (diff)
downloadphosphor-fan-presence-fef0295a8d87754e491dcf133ea927b5c4d56303.tar.gz
phosphor-fan-presence-fef0295a8d87754e491dcf133ea927b5c4d56303.zip
Fill in shell functions/files for cooling type.
Change-Id: I8d18d3141e955adeffdd8122ebb17549c88edd77 Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Diffstat (limited to 'utility.hpp')
-rw-r--r--utility.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/utility.hpp b/utility.hpp
index b37987d..05fe60c 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <sdbusplus/bus.hpp>
+#include <unistd.h>
namespace phosphor
{
@@ -9,6 +10,37 @@ namespace fan
namespace util
{
+class FileDescriptor
+{
+ public:
+ FileDescriptor() = delete;
+ FileDescriptor(const FileDescriptor&) = delete;
+ FileDescriptor(FileDescriptor&&) = default;
+ FileDescriptor& operator=(const FileDescriptor&) = delete;
+ FileDescriptor& operator=(FileDescriptor&&) = default;
+
+ FileDescriptor(int fd) : fd(fd)
+ {
+ }
+
+ ~FileDescriptor()
+ {
+ if (fd != -1)
+ {
+ close(fd);
+ }
+ }
+
+ bool is_open()
+ {
+ return fd != -1;
+ }
+
+ private:
+ int fd = -1;
+
+};
+
/**
* @brief Get the inventory service name from the mapper object
*
OpenPOWER on IntegriCloud