Add path::branch_path to the PBD::sys::path class
This is basically equivalent to Glib::path_get_dirname but returning an empty string(path) if a path doesn't contain any directory components rather than "." git-svn-id: svn://localhost/ardour2/trunk@2403 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user