Add path::leaf method function to the PBD::sys::path class
authorTim Mayberry <mojofunk@gmail.com>
Tue, 4 Sep 2007 09:01:19 +0000 (09:01 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 4 Sep 2007 09:01:19 +0000 (09:01 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2406 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd/filesystem.cc
libs/pbd/pbd/filesystem.h

index 3c96f5b0019e48378b5cf43857b27639a8584b3f..b257da9e336d822dd548f901e1450fcb8aea81b1 100644 (file)
@@ -58,6 +58,12 @@ path::operator/=(const char* rhs)
        return *this;
 }
 
+string
+path::leaf () const
+{
+       return Glib::path_get_basename(m_path);
+}
+
 path
 path::branch_path () const
 {
index 5e94138bd869e39029eb26006d68da6e54c3a6a8..6798a59c84a9d912613d9119f31e44822075f6e6 100644 (file)
@@ -86,6 +86,12 @@ public:
 
        const string to_string() const { return m_path; }
 
+       /**
+        * @return the last component of the path, if the path refers to
+        * a file then it will be the entire filename including any extension.
+        */
+       string leaf() const; 
+
        /**
         * @returns the directory component of a path without any trailing
         * path separator or an empty string if the path has no directory