Returns the position of the root directory in str. If there is no root directory in str, it returns StringRef::npos.
| 112 | // Returns the position of the root directory in str. If there is no root |
| 113 | // directory in str, it returns StringRef::npos. |
| 114 | size_t root_dir_start(StringRef str, Style style) { |
| 115 | // case "c:/" |
| 116 | if (real_style(style) == Style::windows) { |
| 117 | if (str.size() > 2 && str[1] == ':' && is_separator(str[2], style)) |
| 118 | return 2; |
| 119 | } |
| 120 | |
| 121 | // case "//net" |
| 122 | if (str.size() > 3 && is_separator(str[0], style) && str[0] == str[1] && |
| 123 | !is_separator(str[2], style)) { |
| 124 | return str.find_first_of(separators(style), 2); |
| 125 | } |
| 126 | |
| 127 | // case "/" |
| 128 | if (str.size() > 0 && is_separator(str[0], style)) |
| 129 | return 0; |
| 130 | |
| 131 | return StringRef::npos; |
| 132 | } |
| 133 | |
| 134 | // Returns the position past the end of the "parent path" of path. The parent |
| 135 | // path will not end in '/', unless the parent is the root directory. If the |
no test coverage detected