summaryrefslogtreecommitdiffstats
path: root/base/file_util.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 23:31:41 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 23:31:41 +0000
commit7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2 (patch)
treee606471e20eb79fea7a05c9005869065bf865ca1 /base/file_util.cc
parentcab465ccf2a93d84e0f16987d8754ac2673eb118 (diff)
downloadchromium_src-7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2.zip
chromium_src-7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2.tar.gz
chromium_src-7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2.tar.bz2
Convert download manager to FilePath.
(Fixed up version of issue 17032. Now passes all unit tests.) Review URL: http://codereview.chromium.org/16533 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7630 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.cc')
-rw-r--r--base/file_util.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/base/file_util.cc b/base/file_util.cc
index fe33c32..fe7b694 100644
--- a/base/file_util.cc
+++ b/base/file_util.cc
@@ -79,12 +79,13 @@ void TrimTrailingSeparator(std::wstring* dir) {
dir->resize(dir->length() - 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);
+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 GetFilenameWithoutExtensionFromPath(const std::wstring& path) {
@@ -374,6 +375,15 @@ 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);
}