aboutsummaryrefslogtreecommitdiff
path: root/build/path
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-08 13:27:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-08 13:27:15 +0200
commitab4421747146aa7995f0cfb1a639c9121c82c915 (patch)
treedeb08893c02ed0238f73becbbe80ede5568b946e /build/path
parentd3e624ef7c0fb274e62b81c4c7bd59640770520a (diff)
Implement tracing support
Also use to-relative path translation in diagnostics.
Diffstat (limited to 'build/path')
-rw-r--r--build/path19
1 files changed, 19 insertions, 0 deletions
diff --git a/build/path b/build/path
index ccc1b85..92832a1 100644
--- a/build/path
+++ b/build/path
@@ -218,6 +218,16 @@ namespace build
bool
root () const;
+ // Return true if *this is a sub-path of the specified path (i.e.,
+ // the specified path is a prefix). Expects both paths to be
+ // normalized.
+ //
+ bool
+ sub (const basic_path& p) const
+ {
+ return path_.compare (0, p.path_.size (), p.path_) == 0;
+ }
+
public:
// Return the path without the directory part.
//
@@ -249,6 +259,13 @@ namespace build
basic_path
base () const;
+ // Return a path relative to the specified path that is equivalent
+ // to *this. Throws invalid_path if a relative path cannot be derived
+ // (e.g., paths are on different drives on Windows).
+ //
+ basic_path
+ relative (basic_path) const;
+
public:
// Normalize the path. This includes collapsing the '.' and '..'
// directories if possible, collapsing multiple directory
@@ -334,12 +351,14 @@ namespace build
string_type path_;
};
+ /*
template <typename C>
inline std::basic_ostream<C>&
operator<< (std::basic_ostream<C>& os, basic_path<C> const& p)
{
return os << p.string ();
}
+ */
}
#include <build/path.ixx>