summaryrefslogtreecommitdiffstats
path: root/file.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'file.hpp')
-rw-r--r--file.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/file.hpp b/file.hpp
index ae5cf85..7b22b3e 100644
--- a/file.hpp
+++ b/file.hpp
@@ -49,6 +49,23 @@ class File
fp = fopen(name.c_str(), mode.c_str());
}
+ /** @brief Opens file using provided file descriptor
+ *
+ * @param[in] fd - File descriptor
+ * @param[in] name - File name
+ * @param[in] mode - File open mode
+ * @param[in] removeOnExit - File to be removed at exit or no
+ */
+ File(int fd,
+ const std::string& name,
+ const std::string& mode,
+ bool removeOnExit = false) :
+ name(name),
+ removeOnExit(removeOnExit)
+ {
+ fp = fdopen(fd, mode.c_str());
+ }
+
~File()
{
if (fp)
OpenPOWER on IntegriCloud