Add C++ version of function StripBackslash()

This commit is contained in:
Stas Degteff 2011-02-17 19:35:27 +00:00
parent 13d2b4f059
commit 08e43413cf
2 changed files with 13 additions and 0 deletions

View File

@ -200,6 +200,7 @@ std::string& AddBackslash(std::string& p);
// Remove one trailing directory-delimiter character ('\\' in DOS-based, '/' in unix-based OS)
char* StripBackslash(char* p);
std::string& StripBackslash(std::string& p);
// Copy pathname with enviroment variables substitution and adds directory delimiter char.
// Copy not more sizeof(Path) characters (__dst should be type "Path" or equvalence, size is GMAXPATH)

View File

@ -49,6 +49,18 @@ std::string& AddBackslash(std::string& p) {
return p;
}
// ------------------------------------------------------------------
// Remove one trailing directory-delimiter character ('\\' in DOS-based, '/' in unix-based OS)
std::string& StripBackslash(std::string& p) {
std::string::iterator pend = p.end();
if(isslash(*pend))
p.erase(pend);
return p;
}
// ------------------------------------------------------------------
// Add path to filename, if no path is set. Don't chech size of 'path', be careful!