aboutsummaryrefslogtreecommitdiff
path: root/butl
diff options
context:
space:
mode:
Diffstat (limited to 'butl')
-rw-r--r--butl/path14
-rw-r--r--butl/path.ixx13
2 files changed, 22 insertions, 5 deletions
diff --git a/butl/path b/butl/path
index 726bbe6..064c8aa 100644
--- a/butl/path
+++ b/butl/path
@@ -702,13 +702,19 @@ namespace butl
basic_path
base () const;
- // Return the extension or NULL if not present. If not NULL, then
- // the result points to the character past the dot but it is legal
- // to decrement it once to obtain the value with the dot.
+ // Return the extension or NULL if not present. If not empty, then the
+ // result starts with the character past the dot.
//
- const C*
+ string_type
extension () const;
+ // Return the in-place pointer to extension or NULL if not present. If not
+ // NULL, then the result points to the character past the dot but it is
+ // legal to decrement it once to obtain the value with the dot.
+ //
+ const C*
+ extension_cstring () const;
+
// Return a path relative to the specified path that is equivalent
// to *this. Throws invalid_path if a relative path cannot be derived
// (e.g., paths are on different drives on Windows).
diff --git a/butl/path.ixx b/butl/path.ixx
index b1212f4..9705b66 100644
--- a/butl/path.ixx
+++ b/butl/path.ixx
@@ -304,11 +304,22 @@ namespace butl
}
template <typename C, typename K>
- inline const C* basic_path<C, K>::
+ inline typename basic_path<C, K>::string_type basic_path<C, K>::
extension () const
{
const string_type& s (this->path_);
size_type p (traits::find_extension (s));
+ return p != string_type::npos
+ ? string_type (s.c_str () + p + 1)
+ : string_type ();
+ }
+
+ template <typename C, typename K>
+ inline const C* basic_path<C, K>::
+ extension_cstring () const
+ {
+ const string_type& s (this->path_);
+ size_type p (traits::find_extension (s));
return p != string_type::npos ? s.c_str () + p + 1 : nullptr;
}