blob: c0319e80e883bfabe49c7073c7d091fb58092b4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// file : cutl/fs/auto-remove.hxx
// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#ifndef CUTL_FS_AUTO_REMOVE_HXX
#define CUTL_FS_AUTO_REMOVE_HXX
#include <vector>
#include <cutl/fs/path.hxx>
#include <cutl/fs/exception.hxx>
#include <cutl/details/export.hxx>
namespace cutl
{
namespace fs
{
// Remove a file or an empty directory on destruction unless canceled.
//
struct LIBCUTL_EXPORT auto_remove
{
explicit
auto_remove (path const& p)
: path_ (p), canceled_ (false)
{
}
~auto_remove ();
void
cancel ()
{
canceled_ = true;
}
private:
auto_remove (auto_remove const&);
auto_remove&
operator= (auto_remove const&);
private:
path path_;
bool canceled_;
};
// Remove a list of file or aempty directories on destruction unless
// canceled.
//
struct LIBCUTL_EXPORT auto_removes
{
auto_removes (): canceled_ (false) {}
~auto_removes ();
void
add (path const& p)
{
paths_.push_back (p);
}
void
cancel ()
{
canceled_ = true;
}
private:
auto_removes (auto_removes const&);
auto_removes&
operator= (auto_removes const&);
private:
typedef std::vector<path> paths;
paths paths_;
bool canceled_;
};
}
}
#endif // CUTL_FS_AUTO_REMOVE_HXX
|