diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-03-16 11:36:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-03-16 11:36:10 +0200 |
commit | 7a4f1ae238b918fe21671d0d1a5549aeb1fe6425 (patch) | |
tree | 6501d18854cc85644a3e73a857fda82b17b73c45 /libbuild2/file-cache.ixx | |
parent | 99046d23d78d341674bbad3414567f362ffc60cd (diff) |
Define intermediate build results file cache interface
Diffstat (limited to 'libbuild2/file-cache.ixx')
-rw-r--r-- | libbuild2/file-cache.ixx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libbuild2/file-cache.ixx b/libbuild2/file-cache.ixx new file mode 100644 index 0000000..259d348 --- /dev/null +++ b/libbuild2/file-cache.ixx @@ -0,0 +1,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; + } +} |