1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-07-02 14:04:22 +00:00

Add basename() free function.

This commit is contained in:
King_DuckZ 2016-03-08 19:09:20 +01:00
parent 63c703f20d
commit 250b2df846
2 changed files with 12 additions and 0 deletions

View file

@ -204,6 +204,17 @@ namespace mchlib {
return parStream;
}
const boost::string_ref basename (const PathName& parPath) {
static const char* const empty = "";
const auto sz = parPath.atom_count();
if (not sz) {
return boost::string_ref(empty);
}
assert(sz > 0);
return parPath[sz - 1];
}
PathName& PathName::pop_right() {
m_pool.pop();
return *this;

View file

@ -59,6 +59,7 @@ namespace mchlib {
PathName make_relative_path ( const PathName& parBasePath, const PathName& parOtherPath );
std::ostream& operator<< ( std::ostream& parStream, const PathName& parPath );
const boost::string_ref basename ( const PathName& parPath );
} //namespace mchlib
#endif