aboutsummaryrefslogtreecommitdiff
path: root/build/path.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-05 15:00:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-05 15:00:39 +0200
commit7e3f16c393a614e0a951abe3f7237c8169d689a9 (patch)
tree0943dbfad1e0fbf72e0ccd4f85eb2172d6fa91f6 /build/path.txx
parentc0c85b67516653c181fbce7c61c2df3e31e4edd8 (diff)
Determine work, home, and {src,out}_{root,base} directories
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 ()
{