File: common-cleanup.cpp

package info (click to toggle)
osm2pgsql 0.96.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,304 kB
  • sloc: cpp: 11,462; python: 543; sh: 98; makefile: 17
file content (21 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (3)
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