aboutsummaryrefslogtreecommitdiff
path: root/build/path.txx
diff options
context:
space:
mode:
Diffstat (limited to 'build/path.txx')
-rw-r--r--build/path.txx40
1 files changed, 40 insertions, 0 deletions
diff --git a/build/path.txx b/build/path.txx
index 1502071..6a01547 100644
--- a/build/path.txx
+++ b/build/path.txx
@@ -104,6 +104,46 @@ namespace build
}
template <typename C>
+ basic_path<C> basic_path<C>::
+ leaf (basic_path<C> const& d) const
+ {
+ size_type n (d.path_.size ());
+
+ if (n == 0)
+ return *this;
+
+ size_type m (path_.size ());
+
+ if (m < n || path_.compare (0, n, d.path_) != 0)
+ throw invalid_basic_path<C> (path_);
+
+ if (n != m)
+ n++; // Skip the directory separator.
+
+ return basic_path (path_.c_str () + n, m - n);
+ }
+
+ template <typename C>
+ basic_path<C> basic_path<C>::
+ directory (basic_path<C> const& l) const
+ {
+ size_type n (l.path_.size ());
+
+ if (n == 0)
+ return *this;
+
+ size_type m (path_.size ());
+
+ if (m < n || path_.compare (m - n, n, l.path_) != 0)
+ throw invalid_basic_path<C> (path_);
+
+ if (n != m)
+ n++; // Skip the directory separator.
+
+ return basic_path (path_.c_str (), m - n);
+ }
+
+ template <typename C>
basic_path<C>& basic_path<C>::
normalize ()
{