summaryrefslogtreecommitdiff
path: root/src/lib/scoped_temporary.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-12-22 03:58:05 +0000
committerCarl Hetherington <cth@carlh.net>2014-12-22 03:58:05 +0000
commit59f63e2b6d0dba963faee7dfee54fbb48dee396a (patch)
tree29ecb7853c0429a3c8050bde2d147b7d59ff2a8c /src/lib/scoped_temporary.h
parent3f8953593f8f55cef214ca259fe4aa4fa2f25ad4 (diff)
Remove POSIX backtraces; move ScopedTemporary into its own file.
Diffstat (limited to 'src/lib/scoped_temporary.h')
-rw-r--r--src/lib/scoped_temporary.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/lib/scoped_temporary.h b/src/lib/scoped_temporary.h
new file mode 100644
index 000000000..927bce6e7
--- /dev/null
+++ b/src/lib/scoped_temporary.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/filesystem.hpp>
+#include <cstdio>
+
+/** @class ScopedTemporary
+ * @brief A temporary file which is deleted when the ScopedTemporary object goes out of scope.
+ */
+class ScopedTemporary
+{
+public:
+ ScopedTemporary ();
+ ~ScopedTemporary ();
+
+ /** @return temporary filename */
+ boost::filesystem::path file () const {
+ return _file;
+ }
+
+ char const * c_str () const;
+ FILE* open (char const *);
+ void close ();
+
+private:
+ boost::filesystem::path _file;
+ FILE* _open;
+};