diff options
Diffstat (limited to 'utility.hpp')
-rw-r--r-- | utility.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utility.hpp b/utility.hpp index 05fe60c..880545a 100644 --- a/utility.hpp +++ b/utility.hpp @@ -2,6 +2,8 @@ #include <sdbusplus/bus.hpp> #include <unistd.h> +#include <fcntl.h> + namespace phosphor { @@ -31,6 +33,21 @@ class FileDescriptor } } + int operator()() + { + return fd; + } + + void open(const std::string& pathname, int flags) + { + fd = ::open(pathname.c_str(), flags); + if (-1 == fd) + { + throw std::runtime_error( + "Failed to open file device: " + pathname); + } + } + bool is_open() { return fd != -1; |