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
This commit is contained in:
Tim Mayberry 2007-09-04 09:01:15 +00:00
parent 26c4c12fb7
commit 4cf84efe88
2 changed files with 13 additions and 3 deletions

View file

@ -155,8 +155,11 @@ copy_file(const path & from_path, const path & to_path)
string string
basename (const path & p) basename (const path & p)
{ {
// I'm not sure if this works quite the same as boost::filesystem::basename string base = Glib::path_get_basename (p.to_string());
return Glib::path_get_basename (p.to_string ());
string::size_type n = base.rfind ('.');
return base.substr (0, n);
} }
} // namespace sys } // namespace sys

View file

@ -162,7 +162,14 @@ bool remove(const path & p);
*/ */
void copy_file(const path & from_path, const path & to_path); 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); string basename (const path& p);
} // namespace sys } // namespace sys