From 08e43413cf5ee5f7c6654363818c4bb4f11337c2 Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Thu, 17 Feb 2011 19:35:27 +0000 Subject: [PATCH] Add C++ version of function StripBackslash() --- goldlib/gall/gfilutil.h | 1 + goldlib/gall/gfilutl2.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/goldlib/gall/gfilutil.h b/goldlib/gall/gfilutil.h index 4f5cf8f..ee82e59 100644 --- a/goldlib/gall/gfilutil.h +++ b/goldlib/gall/gfilutil.h @@ -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) diff --git a/goldlib/gall/gfilutl2.cpp b/goldlib/gall/gfilutl2.cpp index 7338aa7..526f728 100644 --- a/goldlib/gall/gfilutl2.cpp +++ b/goldlib/gall/gfilutl2.cpp @@ -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!