commit | 60d6f29d61708241268e4f98fc3e64c1fb07a9b3 | [log] [tgz] |
---|---|---|
author | Václav Kubernát <kubervac@fit.cvut.cz> | Fri May 25 09:45:32 2018 +0200 |
committer | Václav Kubernát <kubervac@fit.cvut.cz> | Mon May 28 11:51:46 2018 +0200 |
tree | 050e1487d6bee56a9f4c7e7080a00e03b0a3bed6 | |
parent | 195eeeaa4374ab062390f207c373924572471688 [diff] [blame] |
allow moving up a node with cd Change-Id: Id1419fddda4aa2d2c16b5775a43c8df58db98c73
diff --git a/src/utils.cpp b/src/utils.cpp index 38bfe7d..77466c4 100644 --- a/src/utils.cpp +++ b/src/utils.cpp
@@ -14,3 +14,14 @@ else return prefix + '/' + suffix; } + +std::string stripLastNodeFromPath(const std::string& path) +{ + std::string res = path; + auto pos = res.find_last_of('/'); + if (pos == res.npos) + res.clear(); + else + res.erase(pos); + return res; +}