From dafe9f9fb6c2c71711b172b1e73c2da0664a2bd3 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 22 Aug 2003 22:11:19 +0000 Subject: fixed basename --- src/FbTk/StringUtil.cc | 9 ++++++++- src/FbTk/StringUtil.hh | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 26dbb84..e1af2c2 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: StringUtil.cc,v 1.5 2003/08/22 19:38:00 fluxgen Exp $ +// $Id: StringUtil.cc,v 1.6 2003/08/22 22:11:19 fluxgen Exp $ #include "StringUtil.hh" @@ -171,6 +171,13 @@ std::string toUpper(const std::string &conv) { return ret; } +std::string basename(const std::string &filename) { + std::string::size_type first_pos = filename.find_last_of("/"); + if (first_pos != std::string::npos) + return filename.substr(first_pos + 1); + return filename; +} + }; // end namespace StringUtil }; // end namespace FbTk diff --git a/src/FbTk/StringUtil.hh b/src/FbTk/StringUtil.hh index 0c798ee..621f0fb 100644 --- a/src/FbTk/StringUtil.hh +++ b/src/FbTk/StringUtil.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: StringUtil.hh,v 1.4 2003/08/22 19:37:07 fluxgen Exp $ +//$Id: StringUtil.hh,v 1.5 2003/08/22 22:11:19 fluxgen Exp $ #ifndef FBTK_STRINGUTIL_HH #define FBTK_STRINGUTIL_HH @@ -49,6 +49,10 @@ int getStringBetween(std::string& out, const char *instr, std::string toLower(const std::string &conv); /// @return upper case letters of conv std::string toUpper(const std::string &conv); +#ifdef basename +#undef basename +#endif // basename +std::string basename(const std::string &basename); /// Breaks a string into tokens template -- cgit v0.11.2