15 extern "C" int close(
int);
30 std::vector<char> strbuf(prefix.begin(), prefix.end());
31 strbuf.insert(strbuf.end(), 7,
'X');
34 int fd=mkstemp(&strbuf[0]);
36 throw std::runtime_error(
"Failed to generate a temporary name from template '" 37 + std::string(&strbuf[0]) +
"'");
40 name_.assign(&strbuf[0]);
46 remove(name_.c_str());
~unique_file()
Closes and optionally deletes the file.
unique_file(const std::string &prefix, action_type action=KEEP_AFTER)
Generates a random file name with a given prefix.
Remove the file when destroying the object.
Remove the file after constructing the object only.
Remove the file after constructing the object, remove when destructing too.