]> git.decadent.org.uk Git - videolink.git/blob - auto_temp_file.hpp
5aa3961e861de1bad3599b5fbd3bbb2f40ed1fce
[videolink.git] / auto_temp_file.hpp
1 // Copyright 2005 Ben Hutchings <ben@decadentplace.org.uk>.
2 // See the file "COPYING" for licence details.
3
4 #ifndef INC_AUTO_TEMP_FILE_HPP
5 #define INC_AUTO_TEMP_FILE_HPP
6
7 #include "auto_handle.hpp"
8
9 #include <string>
10
11 #include <unistd.h>
12
13 struct auto_temp_file_closer
14 {
15     void operator()(const std::string & name) const
16         {
17             if (!name.empty())
18                 unlink(name.c_str());
19         }
20 };
21 struct auto_temp_file_factory
22 {
23     std::string operator()() const { return std::string(); }
24 };
25 typedef auto_handle<std::string, auto_temp_file_closer, auto_temp_file_factory>
26     auto_temp_file;
27
28 #endif // !INC_AUTO_TEMP_FILE_HPP