Returns the length of the filesystem name in 'path' which is the length of the 'scheme://authority'. Returns 0 if the path is unqualified.
| 150 | // Returns the length of the filesystem name in 'path' which is the length of the |
| 151 | // 'scheme://authority'. Returns 0 if the path is unqualified. |
| 152 | static int GetFilesystemNameLength(const char* path) { |
| 153 | // Special case for "file:/". It will not have an authority following it. |
| 154 | if (strncmp(path, "file:", 5) == 0) return 5; |
| 155 | |
| 156 | const char* after_scheme = strstr(path, "://"); |
| 157 | if (after_scheme == NULL) return 0; |
| 158 | // Some paths may come only with a scheme. We add 3 to skip over "://". |
| 159 | if (*(after_scheme + 3) == '\0') return strlen(path); |
| 160 | |
| 161 | const char* after_authority = strstr(after_scheme + 3, "/"); |
| 162 | if (after_authority == NULL) return strlen(path); |
| 163 | return after_authority - path; |
| 164 | } |
| 165 | |
| 166 | static bool FilesystemsMatch(const char* path_a, const char* path_b) { |
| 167 | int fs_a_name_length = GetFilesystemNameLength(path_a); |
no outgoing calls
no test coverage detected