Remove file_util::TrimTrailingSeparators(), which is deprecated and
doesn't work well for Windows root drives.
BUG=24722
TEST=existing tests are enough.
Review URL: http://codereview.chromium.org/271086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29093 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 2c8088a4452c2c204237ba9f2f3706e7eeaaf35b
diff --git a/base/file_util.cc b/base/file_util.cc
index d3a989b..9976d88 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -47,11 +47,6 @@
return true;
}
-void TrimTrailingSeparator(std::wstring* dir) {
- while (dir->length() > 1 && EndsWithSeparator(dir))
- dir->resize(dir->length() - 1);
-}
-
FilePath::StringType GetFileExtensionFromPath(const FilePath& path) {
FilePath::StringType file_name = path.BaseName().value();
const FilePath::StringType::size_type last_dot =
diff --git a/base/file_util.h b/base/file_util.h
index 37634b9..93fdd4e 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -47,11 +47,6 @@
// exists. Returns true if |path| is an existing directory, false otherwise.
bool EnsureEndsWithSeparator(FilePath* path);
-// Modifies a string by trimming all trailing separators from the end.
-// Deprecated. FilePath does this automatically, and if it's constructed from a
-// path with a trailing separator, StripTrailingSeparators() may be used.
-void TrimTrailingSeparator(std::wstring* dir);
-
// Strips the topmost directory from the end of 'dir'. Assumes 'dir' does not
// refer to a file.
// If 'dir' is a root directory, return without change.
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index f011580..6c5b86a 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -61,9 +61,9 @@
std::wstring GetDirectoryFromPath(const std::wstring& path) {
if (EndsWithSeparator(path)) {
- std::wstring dir = path;
- TrimTrailingSeparator(&dir);
- return dir;
+ return FilePath::FromWStringHack(path)
+ .StripTrailingSeparators()
+ .ToWStringHack();
} else {
char full_path[PATH_MAX];
base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path));
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index cde98a0..40a4163 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -297,7 +297,7 @@
{L"C:\\WINDOWS\\system32\\\\", L"C:\\WINDOWS\\system32"},
{L"C:\\WINDOWS\\system32", L"C:\\WINDOWS"},
{L"C:\\WINDOWS\\system32.\\", L"C:\\WINDOWS\\system32."},
- {L"C:\\", L"C:"},
+ {L"C:\\", L"C:\\"},
#elif defined(OS_POSIX)
{L"/foo/bar/gdi32.dll", L"/foo/bar"},
{L"/foo/bar/not_exist_thx_1138", L"/foo/bar"},