aboutsummaryrefslogtreecommitdiff
path: root/build/path
diff options
context:
space:
mode:
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>