Index: base/files/file_path.cc |
diff --git a/base/files/file_path.cc b/base/files/file_path.cc |
index 01d9eabd915ef5200d06bd5319ec2e8448e415d5..e9495a1c827f6304e9753915fbeaa4f909ac4c00 100644 |
--- a/base/files/file_path.cc |
+++ b/base/files/file_path.cc |
@@ -521,6 +521,24 @@ bool FilePath::IsAbsolute() const { |
return IsPathAbsolute(path_); |
} |
+bool FilePath::EndsWithSeparator() const { |
+ if (empty()) |
+ return false; |
+ return IsSeparator(path_[path_.size() - 1]); |
+} |
+ |
+FilePath FilePath::AsEndingWithSeparator() const { |
+ if (EndsWithSeparator() || path_.empty()) |
+ return *this; |
+ |
+ StringType path_str; |
+ path_str.reserve(path_.length() + 1); // Only allocate string once. |
+ |
+ path_str = path_; |
+ path_str.append(&kSeparators[0], 1); |
+ return FilePath(path_str); |
+} |
+ |
FilePath FilePath::StripTrailingSeparators() const { |
FilePath new_path(path_); |
new_path.StripTrailingSeparatorsInternal(); |