summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 01:57:43 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 01:57:43 +0000
commit1bdaa60c309250932259402cc8abe0a1bb3f5b2d (patch)
tree642f105b102cde69a867ccebdb54fa9f4b943fe3 /base
parentceea4a852067bb0b6a7977349c091e65b7e72976 (diff)
downloadchromium_src-1bdaa60c309250932259402cc8abe0a1bb3f5b2d.zip
chromium_src-1bdaa60c309250932259402cc8abe0a1bb3f5b2d.tar.gz
chromium_src-1bdaa60c309250932259402cc8abe0a1bb3f5b2d.tar.bz2
Remove deprecated file_util::ReplaceExtension API.
BUG=24672 TEST=out/Debug/base_unittests Review URL: http://codereview.chromium.org/2445001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48614 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util.cc27
-rw-r--r--base/file_util_deprecated.h4
-rw-r--r--base/file_util_unittest.cc44
3 files changed, 0 insertions, 75 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index aea6e62..429ea01 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -76,33 +76,6 @@ void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix) {
value.insert(last_dot, suffix);
}
-void ReplaceExtension(FilePath* path, const FilePath::StringType& extension) {
- FilePath::StringType clean_extension;
- // If the new extension is "" or ".", then we will just remove the current
- // extension.
- if (!extension.empty() &&
- extension != FilePath::StringType(&kExtensionSeparator, 1)) {
- if (extension[0] != kExtensionSeparator)
- clean_extension.append(&kExtensionSeparator, 1);
- clean_extension.append(extension);
- }
-
- FilePath::StringType& value =
- const_cast<FilePath::StringType&>(path->value());
- const FilePath::StringType::size_type last_dot =
- value.rfind(kExtensionSeparator);
- const FilePath::StringType::size_type last_separator =
- value.find_last_of(FilePath::StringType(FilePath::kSeparators));
-
- // Erase the current extension, if any.
- if ((last_dot > last_separator ||
- last_separator == FilePath::StringType::npos) &&
- last_dot != FilePath::StringType::npos)
- value.erase(last_dot);
-
- value.append(clean_extension);
-}
-
bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) {
// We open the file in binary format even if they are text files because
// we are just comparing that bytes are exactly same in both files and not
diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h
index 9a8c5bf..28de811 100644
--- a/base/file_util_deprecated.h
+++ b/base/file_util_deprecated.h
@@ -37,10 +37,6 @@ bool AbsolutePath(std::wstring* path);
// Use FilePath::InsertBeforeExtension.
void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix);
-// Use FilePath::ReplaceExtension.
-void ReplaceExtension(FilePath* file_name,
- const FilePath::StringType& extension);
-
bool Delete(const std::wstring& path, bool recursive);
bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path,
bool recursive);
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 682376a..05a1aee 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1397,50 +1397,6 @@ TEST_F(FileUtilTest, DetectDirectoryTest) {
EXPECT_TRUE(file_util::Delete(test_root, true));
}
-static const struct ReplaceExtensionCase {
- std::wstring file_name;
- FilePath::StringType extension;
- std::wstring result;
-} kReplaceExtension[] = {
- {L"", FILE_PATH_LITERAL(""), L""},
- {L"", FILE_PATH_LITERAL("txt"), L".txt"},
- {L".", FILE_PATH_LITERAL("txt"), L".txt"},
- {L".", FILE_PATH_LITERAL(""), L""},
- {L"foo.dll", FILE_PATH_LITERAL("txt"), L"foo.txt"},
- {L"foo.dll", FILE_PATH_LITERAL(".txt"), L"foo.txt"},
- {L"foo", FILE_PATH_LITERAL("txt"), L"foo.txt"},
- {L"foo", FILE_PATH_LITERAL(".txt"), L"foo.txt"},
- {L"foo.baz.dll", FILE_PATH_LITERAL("txt"), L"foo.baz.txt"},
- {L"foo.baz.dll", FILE_PATH_LITERAL(".txt"), L"foo.baz.txt"},
- {L"foo.dll", FILE_PATH_LITERAL(""), L"foo"},
- {L"foo.dll", FILE_PATH_LITERAL("."), L"foo"},
- {L"foo", FILE_PATH_LITERAL(""), L"foo"},
- {L"foo", FILE_PATH_LITERAL("."), L"foo"},
- {L"foo.baz.dll", FILE_PATH_LITERAL(""), L"foo.baz"},
- {L"foo.baz.dll", FILE_PATH_LITERAL("."), L"foo.baz"},
-};
-
-TEST_F(FileUtilTest, ReplaceExtensionTest) {
- for (unsigned int i = 0; i < arraysize(kReplaceExtension); ++i) {
- FilePath path = FilePath::FromWStringHack(kReplaceExtension[i].file_name);
- file_util::ReplaceExtension(&path, kReplaceExtension[i].extension);
- EXPECT_EQ(kReplaceExtension[i].result, path.ToWStringHack());
- }
-}
-
-// Make sure ReplaceExtension doesn't replace an extension that occurs as one of
-// the directory names of the path.
-TEST_F(FileUtilTest, ReplaceExtensionTestWithPathSeparators) {
- FilePath path;
- path = path.Append(FILE_PATH_LITERAL("foo.bar"));
- path = path.Append(FILE_PATH_LITERAL("foo"));
- // '/foo.bar/foo' with extension '.baz'
- FilePath result_path = path;
- file_util::ReplaceExtension(&result_path, FILE_PATH_LITERAL(".baz"));
- EXPECT_EQ(path.value() + FILE_PATH_LITERAL(".baz"),
- result_path.value());
-}
-
TEST_F(FileUtilTest, FileEnumeratorTest) {
// Test an empty directory.
file_util::FileEnumerator f0(test_dir_, true, FILES_AND_DIRECTORIES);