summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 22:59:05 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-21 22:59:05 +0000
commit33eb5ad09b9cc9fe9f1fb95c4ba41ace5c3b6bc8 (patch)
tree8529954cf39744ce032cbb11013167da1cd3798b /base
parentba6332442ae92c544eb6629c8604c608d6aeb5cd (diff)
downloadchromium_src-33eb5ad09b9cc9fe9f1fb95c4ba41ace5c3b6bc8.zip
chromium_src-33eb5ad09b9cc9fe9f1fb95c4ba41ace5c3b6bc8.tar.gz
chromium_src-33eb5ad09b9cc9fe9f1fb95c4ba41ace5c3b6bc8.tar.bz2
Stop using and remove deprecated file_util::TrimTrailingSeparator().
Review URL: http://codereview.chromium.org/67271 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util.cc5
-rw-r--r--base/file_util.h5
-rw-r--r--base/file_util_posix.cc5
-rw-r--r--base/file_util_win.cc10
-rw-r--r--base/path_service.cc5
5 files changed, 9 insertions, 21 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index ab0ae58..1bf4d5e 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -76,11 +76,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 6728a0d..8f9cfb1 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -55,11 +55,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 6a36c62..2e315ab 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -37,9 +37,8 @@ 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;
+ FilePath fp_path = FilePath::FromWStringHack(path);
+ return fp_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_win.cc b/base/file_util_win.cc
index 8b3d4f5..8020dca 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -28,8 +28,8 @@ 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;
+ FilePath fp_directory(directory);
+ return fp_directory.StripTrailingSeparators().value();
}
bool AbsolutePath(FilePath* path) {
@@ -423,8 +423,7 @@ bool GetTempDir(FilePath* path) {
// trailing slash. We duplicate this here, but it shouldn't be necessary
// when everyone is using the appropriate FilePath APIs.
std::wstring path_str(temp_path);
- TrimTrailingSeparator(&path_str);
- *path = FilePath(path_str);
+ *path = FilePath(path_str).StripTrailingSeparators();
return true;
}
@@ -638,8 +637,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/base/path_service.cc b/base/path_service.cc
index 0c3c3e2..40866d1 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -219,10 +219,11 @@ bool PathService::Override(int key, const std::wstring& path) {
if (!file_util::CreateDirectory(file_path))
return false;
- file_util::TrimTrailingSeparator(&file_path);
+ FilePath fp_path = FilePath::FromWStringHack(file_path);
+ fp_path = fp_path.StripTrailingSeparators();
AutoLock scoped_lock(path_data->lock);
- path_data->cache[key] = FilePath::FromWStringHack(file_path);
+ path_data->cache[key] = fp_path;
path_data->overrides.insert(key);
return true;
}