add noremove option to TempFile

This commit is contained in:
Jean-Francois Dockes
2012-12-20 11:15:43 +01:00
parent 2d5c2a8058
commit 4ceb46b13d
2 changed files with 19 additions and 4 deletions
+2 -1
View File
@@ -148,6 +148,7 @@ bool maketmpdir(string& tdir, string& reason)
}
TempFileInternal::TempFileInternal(const string& suffix)
: m_noremove(false)
{
string filename = path_cat(tmplocation(), "rcltmpfXXXXXX");
char *cp = strdup(filename.c_str());
@@ -179,7 +180,7 @@ TempFileInternal::TempFileInternal(const string& suffix)
TempFileInternal::~TempFileInternal()
{
if (!m_filename.empty())
if (!m_filename.empty() && !m_noremove)
unlink(m_filename.c_str());
}