summaryrefslogtreecommitdiff
path: root/tools/minicargo/path.h
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-09-09 12:42:27 +0800
committerJohn Hodge <tpg@mutabah.net>2017-09-22 09:55:50 +0800
commit6c8c47aaf2ad2f7f300487c935136e38768040b0 (patch)
treea24c87d4d89b63bf9ec96e7698d0f28d22499a45 /tools/minicargo/path.h
parent1cb79ee7f01a198f373e2d85c5ce5ab0bf90dcb6 (diff)
downloadmrust-6c8c47aaf2ad2f7f300487c935136e38768040b0.tar.gz
Tools - Add draft testrunner
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
{