summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2007-09-04 09:01:15 +0000
committerTim Mayberry <mojofunk@gmail.com>2007-09-04 09:01:15 +0000
commit4cf84efe8896d7be295993418bbde9e5d3c0cfee (patch)
tree71037ff1fb67b7424524aed2db0779996558ddf1 /libs/pbd
parent26c4c12fb79e40f908b0357a063bb94d104f9f69 (diff)
Modify PBD::sys::basename to match boost::filesystem behaviour and document it.
This makes this function equivalent to PBD::basename_nosuffix, sys::basename takes a path as an argument rather than a string but that is ok as a path can automatically constructed from a string. git-svn-id: svn://localhost/ardour2/trunk@2404 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/filesystem.cc7
-rw-r--r--libs/pbd/pbd/filesystem.h9
2 files changed, 13 insertions, 3 deletions
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