aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file-cache.ixx
blob: 259d348972ddac5d1cab2039e33c25e9405babfd (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
// file      : libbuild2/file-cache.ixx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <libbuild2/filesystem.hxx> // try_rmfile()

namespace build2
{
  inline file_cache::entry::
  entry (path_type p, bool t)
      : temporary (t), path_ (move (p))
  {
  }

  inline file_cache::entry::
  ~entry ()
  {
    if (!path_.empty () && temporary)
      try_rmfile (path_, true /* ignore_errors */);
  }

  inline file_cache::entry::
  entry (entry&& e)
      : temporary (e.temporary), path_ (move (e.path_))
  {
  }

  inline file_cache::entry& file_cache::entry::
  operator= (entry&& e)
  {
    if (this != &e)
    {
      assert (path_.empty ());
      temporary = e.temporary;
      path_ = move (e.path_);
    }
    return *this;
  }
}