aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/file-cache.ixx
blob: 6d73387d2ac051c391f0694961f921ca5be59cc9 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// file      : libbuild2/file-cache.ixx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

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

namespace build2
{
  // file_cache::write
  //
  inline void file_cache::write::
  close ()
  {
  }

  // file_cache::read
  //
  inline file_cache::read::
  ~read ()
  {
  }

  // file_cache::entry
  //
  inline const path& file_cache::entry::
  path () const
  {
    return path_;
  }

  inline file_cache::write file_cache::entry::
  init_new ()
  {
    return write ();
  }

  inline void file_cache::entry::
  init_existing ()
  {
  }

  inline file_cache::read file_cache::entry::
  open ()
  {
    return read ();
  }

  inline void file_cache::entry::
  pin ()
  {
  }

  inline void file_cache::entry::
  unpin ()
  {
  }

  inline file_cache::entry::
  operator bool () const
  {
    return !path_.empty ();
  }

  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;
  }

  // file_cache
  //
  inline file_cache::entry file_cache::
  create (path f, optional<bool>)
  {
    return entry (move (f), true /* temporary */);
  }

  inline file_cache::entry file_cache::
  create_existing (path f)
  {
    entry e (move (f), false /* temporary */);
    e.init_existing ();
    return e;
  }

  inline string file_cache::
  compressed_extension (const char*)
  {
    return string ();
  }

  inline file_cache::
  file_cache (scheduler&)
  {
  }
}