diff options
Diffstat (limited to 'src/common/string_util.cpp')
| -rw-r--r-- | src/common/string_util.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index e9a2a6b00..124a8937f 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -462,4 +462,27 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_l | |||
| 462 | 462 | ||
| 463 | return std::string(buffer, len); | 463 | return std::string(buffer, len); |
| 464 | } | 464 | } |
| 465 | |||
| 466 | const char* TrimSourcePath(const char* path, const char* root) { | ||
| 467 | const char* p = path; | ||
| 468 | |||
| 469 | while (*p != '\0') { | ||
| 470 | const char* next_slash = p; | ||
| 471 | while (*next_slash != '\0' && *next_slash != '/' && *next_slash != '\\') { | ||
| 472 | ++next_slash; | ||
| 473 | } | ||
| 474 | |||
| 475 | bool is_src = Common::ComparePartialString(p, next_slash, root); | ||
| 476 | p = next_slash; | ||
| 477 | |||
| 478 | if (*p != '\0') { | ||
| 479 | ++p; | ||
| 480 | } | ||
| 481 | if (is_src) { | ||
| 482 | path = p; | ||
| 483 | } | ||
| 484 | } | ||
| 485 | return path; | ||
| 486 | } | ||
| 487 | |||
| 465 | } // namespace Common | 488 | } // namespace Common |