summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd/filesystem.cc18
-rw-r--r--libs/pbd/pbd/filesystem.h7
2 files changed, 25 insertions, 0 deletions
diff --git a/libs/pbd/filesystem.cc b/libs/pbd/filesystem.cc
index 2412b76761..6aaaec1d81 100644
--- a/libs/pbd/filesystem.cc
+++ b/libs/pbd/filesystem.cc
@@ -58,6 +58,24 @@ path::operator/=(const char* rhs)
return *this;
}
+path
+path::branch_path () const
+{
+ string dir = Glib::path_get_dirname (m_path);
+
+ /*
+ * glib returns "." to signify that the path
+ * has no directory components(branch path)
+ * whereas boost::filesystem returns an empty
+ * string
+ */
+ if(dir == ".")
+ {
+ return "";
+ }
+ return dir;
+}
+
bool
exists (const path & p)
{
diff --git a/libs/pbd/pbd/filesystem.h b/libs/pbd/pbd/filesystem.h
index 8de57e4ea7..a5b0ed5b28 100644
--- a/libs/pbd/pbd/filesystem.h
+++ b/libs/pbd/pbd/filesystem.h
@@ -86,6 +86,13 @@ public:
const string to_string() const { return m_path; }
+ /**
+ * @returns the directory component of a path without any trailing
+ * path separator or an empty string if the path has no directory
+ * component(branch path).
+ */
+ path branch_path () const;
+
private:
string m_path;