aboutsummaryrefslogtreecommitdiff
path: root/build2/context.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-08 16:13:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-08 16:13:58 +0200
commit86576cdd3c8d959ffe93f49b7744a99164f172ee (patch)
tree2430017b085cf7b59e335de8efb571d2bc46bfcf /build2/context.txx
parent6205a2d9eb7db0a25959ae34dc5406f228da92a5 (diff)
Move filesystem-related functions from context to new filesystem files
Diffstat (limited to 'build2/context.txx')
-rw-r--r--build2/context.txx101
1 files changed, 0 insertions, 101 deletions
diff --git a/build2/context.txx b/build2/context.txx
index 9223681..6ff61c9 100644
--- a/build2/context.txx
+++ b/build2/context.txx
@@ -2,109 +2,8 @@
// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
-#include <build2/diagnostics>
-
namespace build2
{
- template <typename T>
- fs_status<butl::rmfile_status>
- rmfile (const path& f, const T& t, uint16_t v)
- {
- using namespace butl;
-
- // We don't want to print the command if we couldn't remove the file
- // because it does not exist (just like we don't print the update command
- // if the file is up to date). This makes the below code a bit ugly.
- //
- auto print = [&f, &t, v] ()
- {
- if (verb >= v)
- {
- if (verb >= 2)
- text << "rm " << f;
- else if (verb)
- text << "rm " << t;
- }
- };
-
- rmfile_status rs;
-
- try
- {
- rs = try_rmfile (f);
- }
- catch (const system_error& e)
- {
- print ();
- error << "unable to remove file " << f << ": " << e.what ();
- throw failed ();
- }
-
- if (rs == rmfile_status::success)
- print ();
-
- return rs;
- }
-
- template <typename T>
- fs_status<butl::rmdir_status>
- rmdir (const dir_path& d, const T& t, uint16_t v)
- {
- using namespace butl;
-
- bool w (work.sub (d)); // Don't try to remove working directory.
- rmdir_status rs;
-
- // We don't want to print the command if we couldn't remove the directory
- // because it does not exist (just like we don't print mkdir if it already
- // exists) or if it is not empty. This makes the below code a bit ugly.
- //
- auto print = [&d, &t, v] ()
- {
- if (verb >= v)
- {
- if (verb >= 2)
- text << "rm " << d;
- else if (verb)
- text << "rm " << t;
- }
- };
-
- try
- {
- rs = !w ? try_rmdir (d) : rmdir_status::not_empty;
- }
- catch (const system_error& e)
- {
- print ();
- error << "unable to remove directory " << d << ": " << e.what ();
- throw failed ();
- }
-
- switch (rs)
- {
- case rmdir_status::success:
- {
- print ();
- break;
- }
- case rmdir_status::not_empty:
- {
- if (verb >= v && verb >= 2)
- {
- text << d << " is "
- << (w ? "current working directory" : "not empty")
- << ", not removing";
- }
- break;
- }
- case rmdir_status::not_exist:
- break;
- }
-
- return rs;
- }
-
template <typename K>
basic_path<char, K>
relative (const basic_path<char, K>& p)