mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-16 02:16:09 +01:00
Add PBD::sys::extension for getting the filename extension of a file
git-svn-id: svn://localhost/ardour2/trunk@2405 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4cf84efe88
commit
8b160ef500
2 changed files with 25 additions and 0 deletions
|
|
@ -162,6 +162,22 @@ basename (const path & p)
|
|||
return base.substr (0, n);
|
||||
}
|
||||
|
||||
string
|
||||
extension (const path & p)
|
||||
{
|
||||
string base = Glib::path_get_basename (p.to_string());
|
||||
|
||||
string::size_type n = base.rfind ('.');
|
||||
|
||||
if (n != string::npos)
|
||||
{
|
||||
return base.substr(n);
|
||||
}
|
||||
|
||||
return string();
|
||||
|
||||
}
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace PBD
|
||||
|
|
|
|||
|
|
@ -172,6 +172,15 @@ void copy_file(const path & from_path, const path & to_path);
|
|||
*/
|
||||
string basename (const path& p);
|
||||
|
||||
/**
|
||||
* @return If the filename contains a dot, return a substring of the
|
||||
* filename starting the rightmost dot to the end of the string, otherwise
|
||||
* an empty string.
|
||||
*
|
||||
* @param p a file path.
|
||||
*/
|
||||
string extension (const path& p);
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace PBD
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue