Changeset 1288 for cpp/common/util-string.cpp
- Timestamp:
- 12/06/23 03:32:58 (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/util-string.cpp
r1276 r1288 113 113 } 114 114 115 bool strip_prefix(string& modify_me, const char* prefix) 116 { 117 if (starts_with(modify_me, prefix)) 118 { 119 modify_me = modify_me.substr(strlen(prefix)); 120 return true; 121 } 122 return false; 123 } 115 124 116 125 char* strmove(char *a, char *b) //strcpy that works well for overlapping strings ("Source and destination overlap") … … 162 171 size_t slash = filename.rfind(PATH_SEPARATOR_CHAR); 163 172 if (slash == string::npos) return string(""); 164 return filename.substr(0, slash); 173 return (slash == 0) ? string(PATH_SEPARATOR_STRING) : filename.substr(0, slash); 174 } 175 176 string concatPath(const string& path, const string& other_path) 177 { 178 string result = path; 179 if (!result.empty() && result.back() != PATH_SEPARATOR_CHAR && !other_path.empty()) 180 result += PATH_SEPARATOR_CHAR; 181 result += other_path; 182 return result; 165 183 } 166 184
Note: See TracChangeset
for help on using the changeset viewer.