diff --git a/libs/pbd/filesystem.cc b/libs/pbd/filesystem.cc index 6aaaec1d81..ea45b1da44 100644 --- a/libs/pbd/filesystem.cc +++ b/libs/pbd/filesystem.cc @@ -155,8 +155,11 @@ copy_file(const path & from_path, const path & to_path) string basename (const path & p) { - // I'm not sure if this works quite the same as boost::filesystem::basename - return Glib::path_get_basename (p.to_string ()); + string base = Glib::path_get_basename (p.to_string()); + + string::size_type n = base.rfind ('.'); + + return base.substr (0, n); } } // namespace sys diff --git a/libs/pbd/pbd/filesystem.h b/libs/pbd/pbd/filesystem.h index a5b0ed5b28..b5f328acf4 100644 --- a/libs/pbd/pbd/filesystem.h +++ b/libs/pbd/pbd/filesystem.h @@ -162,7 +162,14 @@ bool remove(const path & p); */ void copy_file(const path & from_path, const path & to_path); - +/** + * @return The substring of the filename component of the path, starting + * at the beginning of the filename up to but not including the last dot. + * + * boost::filesystem::path::basename differs from g_path_get_basename and + * ::basename and most other forms of basename in that it removes the + * extension from the filename if the filename has one. + */ string basename (const path& p); } // namespace sys