Index: base/files/file_path.cc |
diff --git a/base/files/file_path.cc b/base/files/file_path.cc |
index d47becbacca30815ca1284a3aad2a2d229be16cd..f5a9e5a0c3c5f24b9b11ff2bbebbb28fddb462c9 100644 |
--- a/base/files/file_path.cc |
+++ b/base/files/file_path.cc |
@@ -1292,10 +1292,16 @@ void FilePath::StripTrailingSeparatorsInternal() { |
} |
FilePath FilePath::NormalizePathSeparators() const { |
+ return NormalizePathSeparatorsTo(kSeparators[0]); |
+} |
+ |
+FilePath FilePath::NormalizePathSeparatorsTo(CharType separator) const { |
#if defined(FILE_PATH_USES_WIN_SEPARATORS) |
+ DCHECK_NE(kSeparators + kSeparatorsLength, |
+ std::find(kSeparators, kSeparators + kSeparatorsLength, separator)); |
StringType copy = path_; |
- for (size_t i = 1; i < kSeparatorsLength; ++i) { |
- std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); |
+ for (size_t i = 0; i < kSeparatorsLength; ++i) { |
+ std::replace(copy.begin(), copy.end(), kSeparators[i], separator); |
} |
return FilePath(copy); |
#else |