diff options
author | Brandon Wyman <bjwyman@gmail.com> | 2017-03-31 18:13:21 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-05-19 16:19:06 +0000 |
commit | fef0295a8d87754e491dcf133ea927b5c4d56303 (patch) | |
tree | 625df8225e8d9681ff1b5f9afb77104c9e899946 /utility.hpp | |
parent | af5d4c5ec0e07ba7a87ddff3f2066d9b3cbb52f8 (diff) | |
download | phosphor-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.hpp | 32 |
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 * |