317 |
} |
} |
318 |
} |
} |
319 |
|
|
320 |
|
|
321 |
|
/***************************************************************************** |
322 |
|
* Any problems with any of the following helper functions? * |
323 |
|
* * |
324 |
|
* Then please first have a look at their current TEST CASES at * |
325 |
|
* src/testcases/HelperTest.cpp as basis for your modifications! * |
326 |
|
*****************************************************************************/ |
327 |
|
|
328 |
|
|
329 |
/// Removes one or more consecutive occurences of @a needle from the end of @a haystack. |
/// Removes one or more consecutive occurences of @a needle from the end of @a haystack. |
330 |
inline std::string strip2ndFromEndOf1st(const std::string haystack, char needle) { |
inline std::string strip2ndFromEndOf1st(const std::string haystack, char needle) { |
331 |
if (haystack.empty()) return haystack; |
if (haystack.empty()) return haystack; |
351 |
inline std::string parentPath(const std::string path) { |
inline std::string parentPath(const std::string path) { |
352 |
if (path.empty()) return path; |
if (path.empty()) return path; |
353 |
std::string s = strip2ndFromEndOf1st(path, NATIVE_PATH_SEPARATOR); |
std::string s = strip2ndFromEndOf1st(path, NATIVE_PATH_SEPARATOR); |
|
printf("\tstrip('%s') => '%s'\n", path.c_str(), s.c_str()); |
|
354 |
if (s.empty()) { |
if (s.empty()) { |
355 |
s.push_back(NATIVE_PATH_SEPARATOR); // i.e. return "/" |
s.push_back(NATIVE_PATH_SEPARATOR); // i.e. return "/" |
356 |
return s; |
return s; |