| 1 |
// file : cutl/fs/auto-remove.cxx |
| 2 |
// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC |
| 3 |
// license : MIT; see accompanying LICENSE file |
| 4 |
|
| 5 |
#include <cstdio> // std::remove |
| 6 |
#include <cerrno> |
| 7 |
|
| 8 |
#include <cutl/fs/auto-remove.hxx> |
| 9 |
|
| 10 |
namespace cutl |
| 11 |
{ |
| 12 |
namespace fs |
| 13 |
{ |
| 14 |
auto_remove:: |
| 15 |
~auto_remove () |
| 16 |
{ |
| 17 |
if (!canceled_) |
| 18 |
{ |
| 19 |
if (std::remove (path_.string ().c_str ()) == -1) |
| 20 |
throw error (errno); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
auto_removes:: |
| 25 |
~auto_removes () |
| 26 |
{ |
| 27 |
if (!canceled_) |
| 28 |
{ |
| 29 |
for (paths::iterator i (paths_.begin ()); i != paths_.end (); ++i) |
| 30 |
{ |
| 31 |
if (std::remove (i->string ().c_str ()) == -1) |
| 32 |
throw error (errno); |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
} |