src/system/helpers.cpp: Add getBaseName() and getPathName()

Origin commit data
------------------
Branch: ni/coolstream
Commit: 767ff03d98
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-07-03 (Wed, 03 Jul 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2013-07-03 04:48:19 +02:00
parent 99e28fe73d
commit 9e36a9e529
2 changed files with 22 additions and 0 deletions

View File

@@ -284,6 +284,24 @@ bool get_mem_usage(unsigned long &kbtotal, unsigned long &kbfree)
return true;
}
std::string getPathName(std::string &path)
{
size_t pos = path.find_last_of("/");
if (pos == std::string::npos)
return path;
return path.substr(0, pos);
}
std::string getBaseName(std::string &path)
{
size_t pos = path.find_last_of("/");
if (pos == std::string::npos)
return path;
if (path.length() == pos +1)
return "";
return path.substr(pos+1);
}
std::string trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/)
{
std::string result = str.erase(str.find_last_not_of(trimChars) + 1);