summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 02:12:15 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 02:12:15 +0000
commit15e093c9972a9ab2c7dedf23e8a8766fdfc3a41d (patch)
tree17e461be1e026df050079159ca803c57d656c0cd
parent7e6fa7c3f4c3db8f8fe9f1eec8b0a48432e8f6bb (diff)
downloadchromium_src-15e093c9972a9ab2c7dedf23e8a8766fdfc3a41d.zip
chromium_src-15e093c9972a9ab2c7dedf23e8a8766fdfc3a41d.tar.gz
chromium_src-15e093c9972a9ab2c7dedf23e8a8766fdfc3a41d.tar.bz2
Use FilePath::DirName instead of the deprecated file_util::GetDirectoryFromPath.
Fix the callers and remove the deprecated function. BUG=24672 TEST=trybots Review URL: http://codereview.chromium.org/6111003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70705 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/file_util_deprecated.h12
-rw-r--r--base/file_util_unittest.cc12
-rw-r--r--base/file_util_win.cc13
-rw-r--r--chrome/browser/ui/views/shell_dialogs_win.cc2
-rw-r--r--chrome/installer/util/lzma_util.cc15
-rw-r--r--chrome/installer/util/shell_util.cc2
6 files changed, 8 insertions, 48 deletions
diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h
index bb8f7f9..dac4b45 100644
--- a/base/file_util_deprecated.h
+++ b/base/file_util_deprecated.h
@@ -27,18 +27,6 @@ namespace file_util {
FILE* OpenFile(const std::string& filename, const char* mode);
FILE* OpenFile(const std::wstring& filename, const char* mode);
-// Returns the directory component of a path, without the trailing
-// path separator, or an empty string on error. The function does not
-// check for the existence of the path, so if it is passed a directory
-// without the trailing \, it will interpret the last component of the
-// path as a file and chomp it. This does not support relative paths.
-// Examples:
-// path == "C:\pics\jojo.jpg", returns "C:\pics"
-// path == "C:\Windows\system32\", returns "C:\Windows\system32"
-// path == "C:\Windows\system32", returns "C:\Windows"
-// Deprecated. Use FilePath's DirName() instead.
-std::wstring GetDirectoryFromPath(const std::wstring& path);
-
// Appends new_ending to path, adding a separator between the two if necessary.
void AppendToPath(std::wstring* path, const std::wstring& new_ending);
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index fa00fcf..bbd888a 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -315,18 +315,6 @@ static const struct dir_case {
#endif
};
-#if defined(OS_WIN)
-// This function is deprecated, and only exists on Windows anymore.
-TEST_F(FileUtilTest, GetDirectoryFromPath) {
- for (unsigned int i = 0; i < arraysize(dir_cases); ++i) {
- const dir_case& dir = dir_cases[i];
- const std::wstring parent =
- file_util::GetDirectoryFromPath(dir.full_path);
- EXPECT_EQ(dir.directory, parent);
- }
-}
-#endif
-
// Flaky, http://crbug.com/46246
TEST_F(FileUtilTest, FLAKY_CountFilesCreatedAfter) {
// Create old file (that we don't want to count)
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 9ab96c0..7476b53 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -77,19 +77,6 @@ bool DevicePathToDriveLetterPath(const FilePath& device_path,
} // namespace
-std::wstring GetDirectoryFromPath(const std::wstring& path) {
- base::ThreadRestrictions::AssertIOAllowed();
- wchar_t path_buffer[MAX_PATH];
- wchar_t* file_ptr = NULL;
- if (GetFullPathName(path.c_str(), MAX_PATH, path_buffer, &file_ptr) == 0)
- return L"";
-
- std::wstring::size_type length =
- file_ptr ? file_ptr - path_buffer : path.length();
- std::wstring directory(path, 0, length);
- return FilePath(directory).StripTrailingSeparators().value();
-}
-
bool AbsolutePath(FilePath* path) {
base::ThreadRestrictions::AssertIOAllowed();
wchar_t file_path_buf[MAX_PATH];
diff --git a/chrome/browser/ui/views/shell_dialogs_win.cc b/chrome/browser/ui/views/shell_dialogs_win.cc
index 7405ef6..f1c59b4 100644
--- a/chrome/browser/ui/views/shell_dialogs_win.cc
+++ b/chrome/browser/ui/views/shell_dialogs_win.cc
@@ -270,7 +270,7 @@ bool SaveFileAsWithFilter(HWND owner,
save_as.nMaxFileTitle = 0;
// Set up the initial directory for the dialog.
- std::wstring directory = file_util::GetDirectoryFromPath(suggested_name);
+ std::wstring directory = FilePath(suggested_name).DirName().value();
save_as.lpstrInitialDir = directory.c_str();
save_as.lpstrTitle = NULL;
save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING |
diff --git a/chrome/installer/util/lzma_util.cc b/chrome/installer/util/lzma_util.cc
index 8f36b5f..b80fdd9 100644
--- a/chrome/installer/util/lzma_util.cc
+++ b/chrome/installer/util/lzma_util.cc
@@ -158,23 +158,20 @@ DWORD LzmaUtil::UnPack(const std::wstring& location,
break;
}
- // Append location to the file path in archive, to get full path.
- std::wstring wfileName(location);
- file_util::AppendToPath(&wfileName, UTF8ToWide(f->Name));
+ FilePath file_path = FilePath(location).Append(UTF8ToWide(f->Name));
if (output_file)
- *output_file = wfileName;
+ *output_file = file_path.value();
// If archive entry is directory create it and move on to the next entry.
if (f->IsDirectory) {
- file_util::CreateDirectory(FilePath(wfileName));
+ file_util::CreateDirectory(file_path);
continue;
}
- HANDLE hFile;
- std::wstring directory = file_util::GetDirectoryFromPath(wfileName);
- file_util::CreateDirectory(FilePath(directory));
+ file_util::CreateDirectory(file_path.DirName());
- hFile = CreateFile(wfileName.c_str(), GENERIC_WRITE, 0, NULL,
+ HANDLE hFile;
+ hFile = CreateFile(file_path.value().c_str(), GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
ret = GetLastError();
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 1c90453..8d4e643 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -785,7 +785,7 @@ bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
const std::wstring& shortcut,
const std::wstring& description,
bool create_new) {
- std::wstring chrome_path = file_util::GetDirectoryFromPath(chrome_exe);
+ std::wstring chrome_path = FilePath(chrome_exe).DirName().value();
FilePath prefs_path(chrome_path);
prefs_path = prefs_path.AppendASCII(installer::kDefaultMasterPrefs);