mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 23:42:51 +02:00
src/system/helpers.cpp: Add getBaseName() and getPathName()
Origin commit data
------------------
Commit: 767ff03d98
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-07-03 (Wed, 03 Jul 2013)
This commit is contained in:
@@ -284,6 +284,24 @@ bool get_mem_usage(unsigned long &kbtotal, unsigned long &kbfree)
|
|||||||
return true;
|
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 trim(std::string &str, const std::string &trimChars /*= " \n\r\t"*/)
|
||||||
{
|
{
|
||||||
std::string result = str.erase(str.find_last_not_of(trimChars) + 1);
|
std::string result = str.erase(str.find_last_not_of(trimChars) + 1);
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
int my_system(const char * cmd);
|
int my_system(const char * cmd);
|
||||||
int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */
|
int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */
|
||||||
|
|
||||||
@@ -34,6 +36,8 @@ int check_dir(const char * dir);
|
|||||||
bool get_fs_usage(const char * dir, long &total, long &used, long *bsize=NULL);
|
bool get_fs_usage(const char * dir, long &total, long &used, long *bsize=NULL);
|
||||||
bool get_mem_usage(unsigned long &total, unsigned long &free);
|
bool get_mem_usage(unsigned long &total, unsigned long &free);
|
||||||
|
|
||||||
|
std::string getPathName(std::string &path);
|
||||||
|
std::string getBaseName(std::string &path);
|
||||||
std::string trim(std::string &str, const std::string &trimChars = " \n\r\t");
|
std::string trim(std::string &str, const std::string &trimChars = " \n\r\t");
|
||||||
|
|
||||||
class CFileHelpers
|
class CFileHelpers
|
||||||
|
Reference in New Issue
Block a user