Reap invalidation records
[ardour.git] / libs / pbd / basename.cc
index a51e393b78498845a671a60244a888b8a16a9e52..767459f9f9961ed087a1705f5c0d0a9fbe48dd79 100644 (file)
@@ -1,20 +1,32 @@
-#include <iostream>
-#include <string.h>
-#include <pbd/basename.h>
+/*
+    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 <glibmm/miscutils.h>
+
+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 ('.'));
 }