From 49285226d66189e2cea6c8b1fa59a4273ad05bc0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Aug 2015 14:47:11 +0200 Subject: Add "exact" constructor to path --- butl/path.txx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'butl/path.txx') diff --git a/butl/path.txx b/butl/path.txx index 6d418ff..20e9e00 100644 --- a/butl/path.txx +++ b/butl/path.txx @@ -243,14 +243,23 @@ namespace butl } template - void basic_path:: - init () + bool basic_path:: + init (string_type& s, bool exact) { // Strip trailing slashes except for the case where the single // slash represents the root directory. // - size_type n (this->path_.size ()); - for (; n > 1 && traits::is_separator (this->path_[n - 1]); --n) ; - this->path_.resize (n); + size_type n (s.size ()); + for (; n > 1 && traits::is_separator (s[n - 1]); --n) ; + + if (n != s.size ()) + { + if (!exact) + this->path_.resize (n); + + return !exact; + } + + return true; } } -- cgit v1.1