X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fbasename.cc;h=767459f9f9961ed087a1705f5c0d0a9fbe48dd79;hb=1ce58ad90aab58bca10af9c448b8e186ac532480;hp=a51e393b78498845a671a60244a888b8a16a9e52;hpb=481f7c39655afec832ac10430dd61a3bb464aa58;p=ardour.git diff --git a/libs/pbd/basename.cc b/libs/pbd/basename.cc index a51e393b78..767459f9f9 100644 --- a/libs/pbd/basename.cc +++ b/libs/pbd/basename.cc @@ -1,20 +1,32 @@ -#include -#include -#include +/* + Copyright (C) 2000-2007 Paul Davis + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -// implement this using Glib::path_get_basename -std::string -PBD::basename_nosuffix (const std::string& str) + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "pbd/basename.h" +#include + +using Glib::ustring; + +ustring +PBD::basename_nosuffix (ustring str) { - std::string::size_type slash = str.find_last_of ('/'); - std::string noslash; + ustring base = Glib::path_get_basename (str); - if (slash == std::string::npos) { - noslash = str; - } else { - noslash = str.substr (slash+1); - } + return base.substr (0, base.find_last_of ('.')); - return noslash.substr (0, noslash.find_last_of ('.')); }