diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-05 23:36:01 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-05 23:36:01 +0000 |
commit | 345e1b89c38bf19ebce483ae5392474bbf63ae59 (patch) | |
tree | 63f2e61cecbf1f28b876d21c3b8d6e4433220805 /base | |
parent | 6ee68ee792e95e2460ac1f52162f6762944d5239 (diff) | |
download | chromium_src-345e1b89c38bf19ebce483ae5392474bbf63ae59.zip chromium_src-345e1b89c38bf19ebce483ae5392474bbf63ae59.tar.gz chromium_src-345e1b89c38bf19ebce483ae5392474bbf63ae59.tar.bz2 |
Unbreak unit tests. Revert r7564.
tbr=jhawkins
Review URL: http://codereview.chromium.org/16522
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/file_path.cc | 4 | ||||
-rw-r--r-- | base/file_path.h | 4 | ||||
-rw-r--r-- | base/file_path_unittest.cc | 4 | ||||
-rw-r--r-- | base/file_util.cc | 28 | ||||
-rw-r--r-- | base/file_util.h | 2 | ||||
-rw-r--r-- | base/file_util_win.cc | 1 |
6 files changed, 16 insertions, 27 deletions
diff --git a/base/file_path.cc b/base/file_path.cc index 45f6e327..49193152 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -113,7 +113,7 @@ FilePath FilePath::DirName() const { return new_path; } -FilePath FilePath::BaseName() const { +FilePath::StringType FilePath::BaseName() const { FilePath new_path(path_); new_path.StripTrailingSeparatorsInternal(); @@ -133,7 +133,7 @@ FilePath FilePath::BaseName() const { new_path.path_.erase(0, last_separator + 1); } - return new_path; + return new_path.path_; } FilePath FilePath::Append(const FilePath::StringType& component) const { diff --git a/base/file_path.h b/base/file_path.h index e848510..9ba42d3 100644 --- a/base/file_path.h +++ b/base/file_path.h @@ -132,8 +132,6 @@ class FilePath { const StringType& value() const { return path_; } - bool empty() const { return path_.empty(); } - // Returns true if |character| is in kSeparators. static bool IsSeparator(CharType character); @@ -148,7 +146,7 @@ class FilePath { // object, either a file or a directory. If this object already refers to // the root directory, returns a FilePath identifying the root directory; // this is the only situation in which BaseName will return an absolute path. - FilePath BaseName() const; + StringType BaseName() const; // Returns a FilePath by appending a separator and the supplied path // component to this object's path. Append takes care to avoid adding diff --git a/base/file_path_unittest.cc b/base/file_path_unittest.cc index b4ad16f..37fd41a 100644 --- a/base/file_path_unittest.cc +++ b/base/file_path_unittest.cc @@ -209,8 +209,8 @@ TEST_F(FilePathTest, BaseName) { for (size_t i = 0; i < arraysize(cases); ++i) { FilePath input(cases[i].input); - FilePath observed = input.BaseName(); - EXPECT_EQ(FilePath::StringType(cases[i].expected), observed.value()) << + FilePath::StringType observed = input.BaseName(); + EXPECT_EQ(FilePath::StringType(cases[i].expected), observed) << "i: " << i << ", input: " << input.value(); } } diff --git a/base/file_util.cc b/base/file_util.cc index e4c3ae7..f0d66b5 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -79,13 +79,12 @@ void TrimTrailingSeparator(std::wstring* 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 = - file_name.rfind(kExtensionSeparator); - return FilePath::StringType(last_dot == FilePath::StringType::npos ? - FILE_PATH_LITERAL("") : - file_name, last_dot+1); +std::wstring GetFileExtensionFromPath(const std::wstring& path) { + std::wstring file_name = GetFilenameFromPath(path); + std::wstring::size_type last_dot = file_name.rfind(L'.'); + return std::wstring(last_dot == std::wstring::npos ? + L"" : + file_name, last_dot+1); } std::wstring GetFilenameWithoutExtensionFromPath(const std::wstring& path) { @@ -375,15 +374,6 @@ bool GetCurrentDirectory(std::wstring* path_str) { *path_str = path.ToWStringHack(); return true; } -std::wstring GetFileExtensionFromPath(const std::wstring& path) { - FilePath::StringType extension = - GetFileExtensionFromPath(FilePath::FromWStringHack(path)); -#if defined(OS_WIN) - return extension; -#elif defined(OS_POSIX) - return UTF8ToWide(extension); -#endif -} bool GetFileInfo(const std::wstring& file_path, FileInfo* results) { return GetFileInfo(FilePath::FromWStringHack(file_path), results); } @@ -391,7 +381,11 @@ std::wstring GetFilenameFromPath(const std::wstring& path) { if (path.empty() || EndsWithSeparator(path)) return std::wstring(); - return FilePath::FromWStringHack(path).BaseName().ToWStringHack(); +#if defined(OS_WIN) + return FilePath::FromWStringHack(path).BaseName(); +#elif defined(OS_POSIX) + return UTF8ToWide(FilePath::FromWStringHack(path).BaseName()); +#endif } bool GetFileSize(const std::wstring& file_path, int64* file_size) { return GetFileSize(FilePath::FromWStringHack(file_path), file_size); diff --git a/base/file_util.h b/base/file_util.h index cf17cb3..67cd59f 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -77,8 +77,6 @@ std::wstring GetFilenameFromPath(const std::wstring& path); // Returns "jpg" for path "C:\pics\jojo.jpg", or an empty string if // the file has no extension. -FilePath::StringType GetFileExtensionFromPath(const FilePath& path); -// Deprecated temporary compatibility function. std::wstring GetFileExtensionFromPath(const std::wstring& path); // Returns 'jojo' for path "C:\pics\jojo.jpg". diff --git a/base/file_util_win.cc b/base/file_util_win.cc index c2dbf0a..a36f6c9 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -739,7 +739,6 @@ void MemoryMappedFile::CloseHandles() { } // Deprecated functions ---------------------------------------------------- - void InsertBeforeExtension(std::wstring* path_str, const std::wstring& suffix) { FilePath path(*path_str); |