aboutsummaryrefslogtreecommitdiff
path: root/build/path.txx
diff options
context:
space:
mode:
Diffstat (limited to 'build/path.txx')
-rw-r--r--build/path.txx30
1 files changed, 28 insertions, 2 deletions
diff --git a/build/path.txx b/build/path.txx
index 6a01547..3e952d8 100644
--- a/build/path.txx
+++ b/build/path.txx
@@ -117,8 +117,12 @@ namespace build
if (m < n || path_.compare (0, n, d.path_) != 0)
throw invalid_basic_path<C> (path_);
- if (n != m)
- n++; // Skip the directory separator.
+ if (n != m
+#ifndef _WIN32
+ && !d.root ()
+#endif
+ )
+ n++; // Skip the directory separator (unless it is POSIX root).
return basic_path (path_.c_str () + n, m - n);
}
@@ -144,6 +148,28 @@ namespace build
}
template <typename C>
+ basic_path<C> basic_path<C>::
+ relative (basic_path<C> d) const
+ {
+ basic_path r;
+
+ for (;; d = d.directory ())
+ {
+ if (sub (d))
+ break;
+
+ r /= path ("..");
+
+ // Roots of the paths do not match.
+ //
+ if (d.root ())
+ throw invalid_basic_path<C> (path_);
+ }
+
+ return r / leaf (d);
+ }
+
+ template <typename C>
basic_path<C>& basic_path<C>::
normalize ()
{