diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-02 11:24:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-02 11:24:35 +0200 |
commit | 9125ed697fe61abd1a742686e816b44b887a8d69 (patch) | |
tree | 55388511b6ce3361d962a956b66f40a8e96944b8 | |
parent | 17937d1cc8dc96e0be2ce795442f91eb2dbf81da (diff) |
Add C-string overload of path_traits::rfind_separator()
-rw-r--r-- | butl/path | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -135,13 +135,20 @@ namespace butl else pos++; - for (; pos > 0; --pos) + const C* r (rfind_separator (s.c_str (), pos)); + return r != nullptr ? r - s.c_str () : string_type::npos; + } + + static const C* + rfind_separator (const C* s, size_type n) + { + for (; n != 0; --n) { - if (is_separator (s[pos - 1])) - return pos - 1; + if (is_separator (s[n - 1])) + return s + n - 1; } - return string_type::npos; + return nullptr; } // Return the position of '.' or npos if there is no extension. |