Merge master.
[dcpomatic.git] / src / lib / util.h
index 2ae97814cf77726377a4f187c6e2e32d9c186435..a13d7ff734faca494ee0a53c68e923790b4af1f4 100644 (file)
@@ -141,6 +141,28 @@ private:
        char* _old;
 };
 
+/** @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;
+};
 
 #endif