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:
parent
63c703f20d
commit
250b2df846
2 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue