aboutsummaryrefslogtreecommitdiff
path: root/butl/path.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-24 14:47:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-24 14:47:11 +0200
commit49285226d66189e2cea6c8b1fa59a4273ad05bc0 (patch)
treea31593968bd65af23a94caca79aa4d1533ece8b1 /butl/path.txx
parentae19570ed0194d1cdcfafe83286c2238e86d37f3 (diff)
Add "exact" constructor to path
Diffstat (limited to 'butl/path.txx')
-rw-r--r--butl/path.txx19
1 files changed, 14 insertions, 5 deletions
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 <typename C, typename K>
- void basic_path<C, K>::
- init ()
+ bool basic_path<C, K>::
+ 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;
}
}