Return the parts of the basename of path, split on the final ".". If there is no "." in the basename or "." is the final character in the basename, the second value will be empty.
| 96 | // If there is no "." in the basename or "." is the final character in the |
| 97 | // basename, the second value will be empty. |
| 98 | std::pair<StringPiece, StringPiece> SplitBasename(StringPiece path) { |
| 99 | path = Basename(path); |
| 100 | |
| 101 | auto pos = path.rfind('.'); |
| 102 | if (pos == StringPiece::npos) |
| 103 | return std::make_pair(path, StringPiece(path.data() + path.size(), 0)); |
| 104 | return std::make_pair( |
| 105 | StringPiece(path.data(), pos), |
| 106 | StringPiece(path.data() + pos + 1, path.size() - (pos + 1))); |
| 107 | } |
| 108 | |
| 109 | bool FixBazelEnvPath(const char* path, string* out) { |
| 110 | if (path == nullptr) return false; |