diff options
Diffstat (limited to 'build2/utility.txx')
-rw-r--r-- | build2/utility.txx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/build2/utility.txx b/build2/utility.txx index 1c710ee..bba66d6 100644 --- a/build2/utility.txx +++ b/build2/utility.txx @@ -4,6 +4,31 @@ namespace build2 { + template <typename K> + basic_path<char, K> + relative (const basic_path<char, K>& p) + { + typedef basic_path<char, K> path; + + const dir_path& b (*relative_base); + + if (p.simple () || b.empty ()) + return p; + + if (p.sub (b)) + return p.leaf (b); + + if (p.root_directory () == b.root_directory ()) + { + path r (p.relative (b)); + + if (r.string ().size () < p.string ().size ()) + return r; + } + + return p; + } + template <typename T> T run (const process_path& pp, |