1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include "common-cleanup.hpp"
#include <boost/filesystem.hpp>
namespace cleanup {
file::file(const std::string &filename)
: m_filename(filename) {
}
file::~file() {
boost::system::error_code ec;
boost::filesystem::remove(m_filename, ec);
if (ec) {
// not a good idea to throw an exception from a destructor,
// so a warning will have to be good enough.
fprintf(stderr, "WARNING: Unable to remove \"%s\": %s\n",
m_filename.c_str(), ec.message().c_str());
}
}
} // namespace cleanup
|