Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8903)

Unified Diff: base/file_util.cc

Issue 16533: Convert download manager to FilePath. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util.h ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.cc
===================================================================
--- base/file_util.cc (revision 7599)
+++ base/file_util.cc (working copy)
@@ -79,12 +79,13 @@
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 @@
*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);
}
« no previous file with comments | « base/file_util.h ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698