From 710af66724c6ee2a4367db3274d3668544bf1695 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 14 Oct 2016 08:57:23 +0100 Subject: Allow setting open flags --- libadhocutil/fileUtils.cpp | 5 ++--- libadhocutil/fileUtils.h | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libadhocutil/fileUtils.cpp b/libadhocutil/fileUtils.cpp index 0cd3382..7b90e4b 100644 --- a/libadhocutil/fileUtils.cpp +++ b/libadhocutil/fileUtils.cpp @@ -1,5 +1,4 @@ #include "fileUtils.h" -#include #include #include @@ -12,8 +11,8 @@ namespace AdHoc { return *pp; } - FileHandle::FileHandle(const boost::filesystem::path & path) : - fh(open(path.c_str(), O_RDONLY)) + FileHandle::FileHandle(const boost::filesystem::path & path, int flags) : + fh(open(path.c_str(), flags)) { if (fh < 0) { throw std::runtime_error("Failed to open " + path.string()); diff --git a/libadhocutil/fileUtils.h b/libadhocutil/fileUtils.h index a11accb..3fa5756 100644 --- a/libadhocutil/fileUtils.h +++ b/libadhocutil/fileUtils.h @@ -3,6 +3,7 @@ #include #include +#include #include "visibility.h" namespace AdHoc { @@ -11,7 +12,7 @@ namespace AdHoc { class DLL_PUBLIC FileHandle { public: - FileHandle(const boost::filesystem::path & path); + FileHandle(const boost::filesystem::path & path, int flags = O_RDONLY); virtual ~FileHandle(); const int fh; -- cgit v1.2.3