Add TempFile::remove()

This commit is contained in:
Sebastian Messmer 2018-12-22 00:54:04 +01:00
parent fcd239ac65
commit 525c29c65d
2 changed files with 7 additions and 1 deletions

View File

@ -25,13 +25,17 @@ TempFile::TempFile(bool create)
TempFile::~TempFile() { TempFile::~TempFile() {
try { try {
if (exists()) { if (exists()) {
bf::remove(_path); remove();
} }
} catch (const boost::filesystem::filesystem_error &e) { } catch (const boost::filesystem::filesystem_error &e) {
LOG(ERR, "Could not delete tempfile."); LOG(ERR, "Could not delete tempfile.");
} }
} }
void TempFile::remove() {
bf::remove(_path);
}
bool TempFile::exists() const { bool TempFile::exists() const {
return bf::exists(_path); return bf::exists(_path);
} }

View File

@ -15,6 +15,8 @@ public:
const boost::filesystem::path &path() const; const boost::filesystem::path &path() const;
//TODO Test exists() //TODO Test exists()
bool exists() const; bool exists() const;
//TODO Test remove()
void remove();
private: private:
const boost::filesystem::path _path; const boost::filesystem::path _path;