New utility class to make sure temporary files are always deleted

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1043988 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Lukáš Lalinský
2009-11-02 19:53:15 +00:00
parent c962d78a57
commit 44c08b8ca2
10 changed files with 56 additions and 48 deletions

View File

@ -25,3 +25,25 @@ inline void deleteFile(const string &filename)
{
remove(filename.c_str());
}
class ScopedFileCopy
{
public:
ScopedFileCopy(const string &filename, const string &ext)
{
m_filename = copyFile(filename, ext);
}
~ScopedFileCopy()
{
deleteFile(m_filename);
}
string fileName()
{
return m_filename;
}
private:
string m_filename;
};