| 1246 | |
| 1247 | |
| 1248 | void FilePath::StripTrailingSeparatorsInternal() { |
| 1249 | // If there is no drive letter, start will be 1, which will prevent stripping |
| 1250 | // the leading separator if there is only one separator. If there is a drive |
| 1251 | // letter, start will be set appropriately to prevent stripping the first |
| 1252 | // separator following the drive letter, if a separator immediately follows |
| 1253 | // the drive letter. |
| 1254 | StringType::size_type start = FindDriveLetter(path_) + 2; |
| 1255 | |
| 1256 | StringType::size_type last_stripped = StringType::npos; |
| 1257 | for (StringType::size_type pos = path_.length(); |
| 1258 | pos > start && IsSeparator(path_[pos - 1]); |
| 1259 | --pos) { |
| 1260 | // If the string only has two separators and they're at the beginning, |
| 1261 | // don't strip them, unless the string began with more than two separators. |
| 1262 | if (pos != start + 1 || last_stripped == start + 2 || |
| 1263 | !IsSeparator(path_[start - 1])) { |
| 1264 | path_.resize(pos - 1); |
| 1265 | last_stripped = pos; |
| 1266 | } |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | FilePath FilePath::NormalizePathSeparators() const { |
| 1271 | return NormalizePathSeparatorsTo(kSeparators[0]); |
no test coverage detected