Converts: bazel-out/.../(bin|genfiles)/(external/YYY/)?XX to: XX.
| 47 | // bazel-out/.../(bin|genfiles)/(external/YYY/)?XX |
| 48 | // to: XX. |
| 49 | string GetPath(const string& dot_h_fname) { |
| 50 | auto pos = dot_h_fname.find("/bin/"); |
| 51 | string result = dot_h_fname; |
| 52 | if (pos != string::npos) { |
| 53 | // - 1 account for the terminating null character (\0) in "/genfiles/". |
| 54 | result = dot_h_fname.substr(pos + sizeof("/bin/") - 1); |
| 55 | } else { |
| 56 | pos = dot_h_fname.find("/genfiles/"); |
| 57 | if (pos != string::npos) { |
| 58 | result = dot_h_fname.substr(pos + sizeof("/genfiles/") - 1); |
| 59 | } |
| 60 | } |
| 61 | if (result.size() > sizeof("external/") && |
| 62 | result.compare(0, sizeof("external/") - 1, "external/") == 0) { |
| 63 | result = result.substr(sizeof("external/") - 1); |
| 64 | pos = result.find("/"); |
| 65 | if (pos != string::npos) { |
| 66 | result = result.substr(pos + 1); |
| 67 | } |
| 68 | } |
| 69 | return result; |
| 70 | } |
| 71 | |
| 72 | // Converts: some/path/to/file.xx |
| 73 | // to: file |
no test coverage detected