From 66684c6690d43c8f3277e1b07e1d86b372cd5f3a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 8 Jul 2014 12:24:56 -0400 Subject: Add PBD::get_suffix() for ripping file suffixes from paths --- libs/pbd/file_utils.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libs/pbd/file_utils.cc') diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 311d22f9e0..0877ceacbc 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -336,6 +336,16 @@ get_absolute_path (const std::string & p) return Glib::build_filename (Glib::get_current_dir(), p); } +std::string +get_suffix (const std::string & p) +{ + string::size_type period = p.find_last_of ('.'); + if (period == string::npos || period == p.length() - 1) { + return string(); + } + return p.substr (period+1); +} + bool equivalent_paths (const std::string& a, const std::string& b) { -- cgit v1.2.3