fixed basename
This commit is contained in:
parent
062768a077
commit
dafe9f9fb6
2 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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 <typename Container>
|
||||
|
|
Loading…
Reference in a new issue