summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_util.h11
-rw-r--r--base/file_util_win.cc17
-rw-r--r--chrome/browser/importer/ie_importer.cc34
-rw-r--r--chrome/test/reliability/page_load_test.cc17
4 files changed, 29 insertions, 50 deletions
diff --git a/base/file_util.h b/base/file_util.h
index 7598621..d622fb2 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -40,11 +40,6 @@ namespace file_util {
// Returns a vector of all of the components of the provided path.
void PathComponents(const FilePath& path,
std::vector<FilePath::StringType>* components);
-#if defined(OS_WIN)
-// Deprecated temporary compatibility function.
-void PathComponents(const std::wstring& path,
- std::vector<std::wstring>* components);
-#endif
// Returns true if the given path ends with a path separator character.
bool EndsWithSeparator(const FilePath& path);
@@ -112,12 +107,6 @@ void InsertBeforeExtension(FilePath* path, const FilePath::StringType& suffix);
void ReplaceExtension(FilePath* file_name,
const FilePath::StringType& extension);
-#if defined(OS_WIN)
-// Deprecated temporary compatibility functions.
-void InsertBeforeExtension(std::wstring* path, const std::wstring& suffix);
-void ReplaceExtension(std::wstring* file_name, const std::wstring& extension);
-#endif
-
// Replaces characters in 'file_name' that are illegal for file names with
// 'replace_char'. 'file_name' must not be a full or relative path, but just the
// file name component. Any leading or trailing whitespace in 'file_name' is
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 77247a4..f59f87d 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -809,21 +809,4 @@ void MemoryMappedFile::CloseHandles() {
length_ = INVALID_FILE_SIZE;
}
-// Deprecated functions ----------------------------------------------------
-
-void InsertBeforeExtension(std::wstring* path_str,
- const std::wstring& suffix) {
- FilePath path(*path_str);
- InsertBeforeExtension(&path, suffix);
- path_str->assign(path.value());
-}
-void PathComponents(const std::wstring& path,
- std::vector<std::wstring>* components) {
- PathComponents(FilePath(path), components);
-}
-void ReplaceExtension(std::wstring* file_name, const std::wstring& extension) {
- FilePath path(*file_name);
- ReplaceExtension(&path, extension);
- file_name->assign(path.value());
-}
} // namespace file_util
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc
index fe27b12..4ccfdf8 100644
--- a/chrome/browser/importer/ie_importer.cc
+++ b/chrome/browser/importer/ie_importer.cc
@@ -475,21 +475,23 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info,
std::wstring ie_folder = l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_IE);
BookmarkVector toolbar_bookmarks;
FilePath file;
- std::vector<std::wstring> file_list;
+ std::vector<FilePath::StringType> file_list;
+ FilePath favorites_path(info.path);
+ // Favorites path length. Make sure it doesn't include the trailing \.
+ size_t favorites_path_len =
+ favorites_path.StripTrailingSeparators().value().size();
file_util::FileEnumerator file_enumerator(
- FilePath::FromWStringHack(info.path), true,
- file_util::FileEnumerator::FILES);
+ favorites_path, true, file_util::FileEnumerator::FILES);
while (!(file = file_enumerator.Next()).value().empty() && !cancelled())
- file_list.push_back(file.ToWStringHack());
+ file_list.push_back(file.value());
// Keep the bookmarks in alphabetical order.
std::sort(file_list.begin(), file_list.end());
- for (std::vector<std::wstring>::iterator it = file_list.begin();
+ for (std::vector<FilePath::StringType>::iterator it = file_list.begin();
it != file_list.end(); ++it) {
- std::wstring filename = file_util::GetFilenameFromPath(*it);
- std::wstring extension = file_util::GetFileExtensionFromPath(filename);
- if (!LowerCaseEqualsASCII(extension, "url"))
+ FilePath shortcut(*it);
+ if (!LowerCaseEqualsASCII(shortcut.Extension(), ".url"))
continue;
// Skip the bookmark with invalid URL.
@@ -497,13 +499,19 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info,
if (!url.is_valid())
continue;
- // Remove the dot and the file extension, and the directory path.
- std::wstring relative_path = it->substr(info.path.size(),
- it->size() - filename.size() - info.path.size());
- TrimString(relative_path, L"\\", &relative_path);
+ // Make the relative path from the Favorites folder, without the basename.
+ // ex. Suppose that the Favorites folder is C:\Users\Foo\Favorites.
+ // C:\Users\Foo\Favorites\Foo.url -> ""
+ // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar"
+ FilePath::StringType relative_string =
+ shortcut.DirName().value().substr(favorites_path_len);
+ if (relative_string.size() > 0 && FilePath::IsSeparator(relative_string[0]))
+ relative_string = relative_string.substr(1);
+ FilePath relative_path(relative_string);
ProfileWriter::BookmarkEntry entry;
- entry.title = filename.substr(0, filename.size() - (extension.size() + 1));
+ // Remove the dot, the file extension, and the directory path.
+ entry.title = shortcut.RemoveExtension().BaseName().value();
entry.url = url;
entry.creation_time = GetFileCreationTime(*it);
if (!relative_path.empty())
diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc
index 774b7f0..4a7b951 100644
--- a/chrome/test/reliability/page_load_test.cc
+++ b/chrome/test/reliability/page_load_test.cc
@@ -439,22 +439,21 @@ class PageLoadTest : public UITest {
}
}
- std::wstring ConstructSavedDebugLogPath(const std::wstring& debug_log_path,
- int index) {
- std::wstring saved_debug_log_path(debug_log_path);
+ FilePath ConstructSavedDebugLogPath(const FilePath& debug_log_path,
+ int index) {
std::wstring suffix(L"_");
suffix.append(IntToWString(index));
- file_util::InsertBeforeExtension(&saved_debug_log_path, suffix);
- return saved_debug_log_path;
+ return debug_log_path.InsertBeforeExtension(suffix);
}
void SaveDebugLog(const std::wstring& log_path, const std::wstring& log_id,
std::ofstream& log_file, int index) {
if (!log_path.empty()) {
- std::wstring saved_log_path =
- ConstructSavedDebugLogPath(log_path, index);
- if (file_util::Move(log_path, saved_log_path)) {
- log_file << " " << log_id << "=" << saved_log_path;
+ FilePath log_file_path(log_path);
+ FilePath saved_log_file_path =
+ ConstructSavedDebugLogPath(log_file_path, index);
+ if (file_util::Move(log_file_path, saved_log_file_path)) {
+ log_file << " " << log_id << "=" << saved_log_file_path.value();
}
}
}