summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_util.cc5
-rw-r--r--base/file_util.h5
-rw-r--r--base/file_util_posix.cc6
-rw-r--r--base/file_util_unittest.cc2
-rw-r--r--base/file_util_win.cc6
-rw-r--r--chrome/test/mini_installer_test/chrome_mini_installer.cc11
6 files changed, 11 insertions, 24 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index d3a989b5..9976d88 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -47,11 +47,6 @@ bool EnsureEndsWithSeparator(FilePath* path) {
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 @@ bool EndsWithSeparator(const std::wstring& path);
// 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 @@ static const char* kTempFileName = "org.chromium.XXXXXX";
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 @@ static const struct dir_case {
{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"},
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 2d4a694..d6edc6f 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -28,8 +28,7 @@ std::wstring GetDirectoryFromPath(const std::wstring& path) {
std::wstring::size_type length =
file_ptr ? file_ptr - path_buffer : path.length();
std::wstring directory(path, 0, length);
- TrimTrailingSeparator(&directory);
- return directory;
+ return FilePath(directory).StripTrailingSeparators().value();
}
bool AbsolutePath(FilePath* path) {
@@ -651,8 +650,7 @@ bool GetCurrentDirectory(FilePath* dir) {
// trailing slash. We duplicate this here, but it shouldn't be necessary
// when everyone is using the appropriate FilePath APIs.
std::wstring dir_str(system_buffer);
- file_util::TrimTrailingSeparator(&dir_str);
- *dir = FilePath(dir_str);
+ *dir = FilePath(dir_str).StripTrailingSeparators();
return true;
}
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc
index 75fab2d8..79eb1d7 100644
--- a/chrome/test/mini_installer_test/chrome_mini_installer.cc
+++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc
@@ -353,21 +353,20 @@ bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall(
// Deletes Installer folder from Applications directory.
void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) {
- std::wstring install_path = GetChromeInstallDirectoryLocation();
+ FilePath install_path(GetChromeInstallDirectoryLocation());
if (wcscmp(folder_name, L"version_folder") == 0) {
std::wstring delete_path;
delete_path = mini_installer_constants::kChromeAppDir;
std::wstring build_number;
GetChromeVersionFromRegistry(&build_number);
delete_path = delete_path + build_number;
- file_util::AppendToPath(&install_path, delete_path);
+ install_path = install_path.Append(delete_path);
} else if (wcscmp(folder_name,
mini_installer_constants::kChromeAppDir) == 0) {
- file_util::AppendToPath(&install_path, folder_name);
- file_util::TrimTrailingSeparator(&install_path);
+ install_path = install_path.Append(folder_name).StripTrailingSeparators();
}
- printf("This path will be deleted: %ls\n", install_path.c_str());
- ASSERT_TRUE(file_util::Delete(install_path.c_str(), true));
+ printf("This path will be deleted: %ls\n", install_path.value().c_str());
+ ASSERT_TRUE(file_util::Delete(install_path, true));
}
// Will delete user data profile.