Revision: 44682
http://brlcad.svn.sourceforge.net/brlcad/?rev=44682&view=rev
Author: davidloman
Date: 2011-05-25 13:12:19 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Add getLastStepOfPath() to StringUtils.
Modified Paths:
--------------
geomcore/trunk/include/StringUtils.h
geomcore/trunk/src/utility/StringUtils.cxx
Modified: geomcore/trunk/include/StringUtils.h
===================================================================
--- geomcore/trunk/include/StringUtils.h 2011-05-25 12:28:19 UTC (rev
44681)
+++ geomcore/trunk/include/StringUtils.h 2011-05-25 13:12:19 UTC (rev
44682)
@@ -93,7 +93,13 @@
std::string* rPath,
int* totalSteps);
+ /**
+ * Determines and returns the last step of the provided 'path'.
+ * Steps are determined by PATH_DELIM.
+ */
+ static std::string getLastStepOfPath(const std::string path);
+
private:
StringUtils();
Modified: geomcore/trunk/src/utility/StringUtils.cxx
===================================================================
--- geomcore/trunk/src/utility/StringUtils.cxx 2011-05-25 12:28:19 UTC (rev
44681)
+++ geomcore/trunk/src/utility/StringUtils.cxx 2011-05-25 13:12:19 UTC (rev
44682)
@@ -164,6 +164,19 @@
return step;
}
+std::string
+StringUtils::getLastStepOfPath(const std::string path)
+{
+ std::string out = "";
+ size_t found = path.rfind(PATH_DELIM);
+ if (found == std::string::npos)
+ /* Path, so get last step */
+ out = path.substr(found + 1);
+ else
+ /* no path, thus 'path' *is* the last step */
+ out = path;
+ return out;
+}
// Local Variables:
// tab-width: 8
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits