aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/project-name.cxx8
-rw-r--r--libbutl/project-name.mxx6
2 files changed, 12 insertions, 2 deletions
diff --git a/libbutl/project-name.cxx b/libbutl/project-name.cxx
index 5f94ea0..76a68b9 100644
--- a/libbutl/project-name.cxx
+++ b/libbutl/project-name.cxx
@@ -81,11 +81,17 @@ namespace butl
}
string project_name::
- base () const
+ base (const char* e) const
{
using std::string;
size_t p (path::traits::find_extension (value_));
+
+ if (e != nullptr &&
+ p != string::npos &&
+ casecmp (value_.c_str () + p + 1, e) != 0)
+ p = string::npos;
+
return string (value_, 0, p);
}
diff --git a/libbutl/project-name.mxx b/libbutl/project-name.mxx
index 6b5afc7..943ec8c 100644
--- a/libbutl/project-name.mxx
+++ b/libbutl/project-name.mxx
@@ -79,8 +79,12 @@ LIBBUTL_MODEXPORT namespace butl
// extension, then the base name is the same as the full name and the
// returned extension is empty.
//
+ // If the ext argument is not NULL, then only remove the specified
+ // extension. Note that the extension should not include the dot and the
+ // comparison is always case-insensitive.
+ //
std::string
- base () const;
+ base (const char* ext = nullptr) const;
std::string
extension () const;