summaryrefslogtreecommitdiff
path: root/tools/minicargo/path.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/minicargo/path.h')
-rw-r--r--tools/minicargo/path.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/minicargo/path.h b/tools/minicargo/path.h
index 833fe90a..dd97f9be 100644
--- a/tools/minicargo/path.h
+++ b/tools/minicargo/path.h
@@ -116,6 +116,21 @@ public:
}
}
path to_absolute() const;
+ ::std::string basename() const
+ {
+ if(!this->is_valid())
+ throw ::std::runtime_error("Calling basename() on an invalid path");
+
+ auto pos = m_str.find_last_of(SEP);
+ if(pos == ::std::string::npos)
+ {
+ return m_str;
+ }
+ else
+ {
+ return m_str.substr(pos+1);
+ }
+ }
const ::std::string& str() const
{