summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-10-14 08:57:23 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-10-14 08:57:23 +0100
commit710af66724c6ee2a4367db3274d3668544bf1695 (patch)
tree2b125fbe31aec6e544e7d5ab53df50faceb6860a
parentMigrate extensible lexer from gentoobrowse-api (diff)
downloadlibadhocutil-710af66724c6ee2a4367db3274d3668544bf1695.tar.bz2
libadhocutil-710af66724c6ee2a4367db3274d3668544bf1695.tar.xz
libadhocutil-710af66724c6ee2a4367db3274d3668544bf1695.zip
Allow setting open flags
-rw-r--r--libadhocutil/fileUtils.cpp5
-rw-r--r--libadhocutil/fileUtils.h3
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 <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
@@ -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 <boost/filesystem/path.hpp>
#include <sys/stat.h>
+#include <fcntl.h>
#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;