summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/file_path.cc17
-rw-r--r--base/file_path.h13
-rw-r--r--base/file_util.h16
-rw-r--r--base/file_util_posix.cc24
-rw-r--r--base/file_util_unittest.cc33
-rw-r--r--base/file_util_win.cc35
-rw-r--r--chrome/browser/extensions/extensions_service.cc17
-rw-r--r--chrome/browser/greasemonkey_master.cc8
-rw-r--r--chrome/browser/history/text_database_manager.cc7
-rw-r--r--chrome/browser/importer/firefox2_importer.cc8
-rw-r--r--chrome/browser/importer/ie_importer.cc9
-rw-r--r--chrome/browser/printing/printing_layout_uitest.cc7
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_unittest.cc5
-rw-r--r--chrome/browser/user_data_manager.cc8
-rw-r--r--net/base/directory_lister.cc4
-rw-r--r--net/disk_cache/cache_util_posix.cc5
-rw-r--r--net/tools/dump_cache/dump_files.cc5
-rw-r--r--webkit/tools/test_shell/image_decoder_unittest.cc5
18 files changed, 126 insertions, 100 deletions
diff --git a/base/file_path.cc b/base/file_path.cc
index 0856029..a938ca6 100644
--- a/base/file_path.cc
+++ b/base/file_path.cc
@@ -77,7 +77,7 @@ bool FilePath::IsSeparator(CharType character) {
// adhere to their behavior.
FilePath FilePath::DirName() const {
FilePath new_path(path_);
- new_path.StripTrailingSeparators();
+ new_path.StripTrailingSeparatorsInternal();
// The drive letter, if any, always needs to remain in the output. If there
// is no drive letter, as will always be the case on platforms which do not
@@ -104,7 +104,7 @@ FilePath FilePath::DirName() const {
new_path.path_.resize(last_separator);
}
- new_path.StripTrailingSeparators();
+ new_path.StripTrailingSeparatorsInternal();
if (!new_path.path_.length())
new_path.path_ = kCurrentDirectory;
@@ -113,7 +113,7 @@ FilePath FilePath::DirName() const {
FilePath FilePath::BaseName() const {
FilePath new_path(path_);
- new_path.StripTrailingSeparators();
+ new_path.StripTrailingSeparatorsInternal();
// The drive letter, if any, is always stripped.
StringType::size_type letter = FindDriveLetter(new_path.path_);
@@ -148,7 +148,7 @@ FilePath FilePath::Append(const FilePath::StringType& component) const {
}
FilePath new_path(path_);
- new_path.StripTrailingSeparators();
+ new_path.StripTrailingSeparatorsInternal();
// Don't append a separator if the path is empty (indicating the current
// directory) or if the path component is empty (indicating nothing to
@@ -201,7 +201,14 @@ std::wstring FilePath::ToWStringHack() const {
}
#endif
-void FilePath::StripTrailingSeparators() {
+FilePath FilePath::StripTrailingSeparators() const {
+ FilePath new_path(path_);
+ new_path.StripTrailingSeparatorsInternal();
+
+ return new_path;
+}
+
+void FilePath::StripTrailingSeparatorsInternal() {
// If there is no drive letter, start will be 1, which will prevent stripping
// the leading separator if there is only one separator. If there is a drive
// letter, start will be set appropriately to prevent stripping the first
diff --git a/base/file_path.h b/base/file_path.h
index fb2cc57..9049176 100644
--- a/base/file_path.h
+++ b/base/file_path.h
@@ -67,8 +67,8 @@
#include <string>
-#include "base/compiler_specific.h"
#include "base/basictypes.h"
+#include "base/compiler_specific.h"
// Windows-style drive letter support and pathname separator characters can be
// enabled and disabled independently, to aid testing. These #defines are
@@ -121,6 +121,11 @@ class FilePath {
return path_ == that.path_;
}
+ // Required for some STL containers and operations
+ bool operator<(const FilePath& that) const {
+ return path_ < that.path_;
+ }
+
const StringType& value() const { return path_; }
// Returns true if |character| is in kSeparators.
@@ -154,6 +159,10 @@ class FilePath {
// platforms, an absolute path begins with a separator character.
bool IsAbsolute() const;
+ // Returns a copy of this FilePath that does not end with a trailing
+ // separator.
+ FilePath StripTrailingSeparators() const;
+
// Older Chromium code assumes that paths are always wstrings.
// This function converts a wstring to a FilePath, and is useful to smooth
// porting that old code to the FilePath API.
@@ -174,7 +183,7 @@ class FilePath {
// directory, so "////" will become "/", not "". A leading pair of
// separators is never stripped, to support alternate roots. This is used to
// support UNC paths on Windows.
- void StripTrailingSeparators();
+ void StripTrailingSeparatorsInternal();
StringType path_;
};
diff --git a/base/file_util.h b/base/file_util.h
index 41bc70b..7bc7e820 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -51,6 +51,8 @@ bool EndsWithSeparator(const std::wstring& path);
bool EnsureEndsWithSeparator(FilePath* path);
// Modifies a string by trimming all trailing separators from the end.
+// Deprecated. FilePath does this automatically, and if it's constructed from a
+// path with a trailing separator, StripTrailingSeparators() may be used.
void TrimTrailingSeparator(std::wstring* dir);
// Strips the topmost directory from the end of 'dir'. Assumes 'dir' does not
@@ -373,26 +375,26 @@ class FileEnumerator {
// NOTE: the pattern only matches the contents of root_path, not files in
// recursive subdirectories.
// TODO(erikkay): Fix the pattern matching to work at all levels.
- FileEnumerator(const std::wstring& root_path,
+ FileEnumerator(const FilePath& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type);
- FileEnumerator(const std::wstring& root_path,
+ FileEnumerator(const FilePath& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type,
- const std::wstring& pattern);
+ const FilePath::StringType& pattern);
~FileEnumerator();
// Returns an empty string if there are no more results.
- std::wstring Next();
+ FilePath Next();
// Write the file info into |info|.
void GetFindInfo(FindInfo* info);
private:
- std::wstring root_path_;
+ FilePath root_path_;
bool recursive_;
FILE_TYPE file_type_;
- std::wstring pattern_; // Empty when we want to find everything.
+ FilePath pattern_; // Empty when we want to find everything.
// Set to true when there is a find operation open. This way, we can lazily
// start the operations when the caller calls Next().
@@ -400,7 +402,7 @@ class FileEnumerator {
// A stack that keeps track of which subdirectories we still need to
// enumerate in the breadth-first search.
- std::stack<std::wstring> pending_paths_;
+ std::stack<FilePath> pending_paths_;
#if defined(OS_WIN)
WIN32_FIND_DATA find_data_;
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 5760a68..153f70a 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -378,7 +378,7 @@ bool SetCurrentDirectory(const FilePath& path) {
return !ret;
}
-FileEnumerator::FileEnumerator(const std::wstring& root_path,
+FileEnumerator::FileEnumerator(const FilePath& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type)
: recursive_(recursive),
@@ -388,19 +388,19 @@ FileEnumerator::FileEnumerator(const std::wstring& root_path,
pending_paths_.push(root_path);
}
-FileEnumerator::FileEnumerator(const std::wstring& root_path,
+FileEnumerator::FileEnumerator(const FilePath& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type,
- const std::wstring& pattern)
+ const FilePath::StringType& pattern)
: recursive_(recursive),
file_type_(file_type),
- pattern_(root_path),
+ pattern_(root_path.value()),
is_in_find_op_(false),
fts_(NULL) {
// The Windows version of this code only matches against items in the top-most
// directory, and we're comparing fnmatch against full paths, so this is the
// easiest way to get the right pattern.
- AppendToPath(&pattern_, pattern);
+ pattern_ = pattern_.Append(pattern);
pending_paths_.push(root_path);
}
@@ -423,20 +423,20 @@ void FileEnumerator::GetFindInfo(FindInfo* info) {
// the fts enumeration doesn't match (type, pattern, etc.). In the case of
// large directories with many files this can be quite deep.
// TODO(erikkay) - get rid of this recursive pattern
-std::wstring FileEnumerator::Next() {
+FilePath FileEnumerator::Next() {
if (!is_in_find_op_) {
if (pending_paths_.empty())
- return std::wstring();
+ return FilePath();
// The last find FindFirstFile operation is done, prepare a new one.
root_path_ = pending_paths_.top();
- TrimTrailingSeparator(&root_path_);
+ root_path_ = root_path_.StripTrailingSeparators();
pending_paths_.pop();
// Start a new find operation.
int ftsflags = FTS_LOGICAL;
char top_dir[PATH_MAX];
- base::strlcpy(top_dir, WideToUTF8(root_path_).c_str(), sizeof(top_dir));
+ base::strlcpy(top_dir, root_path_.value().c_str(), sizeof(top_dir));
char* dir_list[2] = { top_dir, NULL };
fts_ = fts_open(dir_list, ftsflags, NULL);
if (!fts_)
@@ -458,15 +458,15 @@ std::wstring FileEnumerator::Next() {
// Patterns are only matched on the items in the top-most directory.
// (see Windows implementation)
- if (fts_ent_->fts_level == 1 && pattern_.length() > 0) {
- if (fnmatch(WideToUTF8(pattern_).c_str(), fts_ent_->fts_path, 0) != 0) {
+ if (fts_ent_->fts_level == 1 && pattern_.value().length() > 0) {
+ if (fnmatch(pattern_.value().c_str(), fts_ent_->fts_path, 0) != 0) {
if (fts_ent_->fts_info == FTS_D)
fts_set(fts_, fts_ent_, FTS_SKIP);
return Next();
}
}
- std::wstring cur_file(UTF8ToWide(fts_ent_->fts_path));
+ FilePath cur_file(fts_ent_->fts_path);
if (fts_ent_->fts_info == FTS_D) {
// If not recursive, then prune children.
if (!recursive_)
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 4c7743a..a8855e9 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -55,9 +55,9 @@ class FileUtilTest : public PlatformTest {
class FindResultCollector {
public:
FindResultCollector(file_util::FileEnumerator& enumerator) {
- std::wstring cur_file;
- while (!(cur_file = enumerator.Next()).empty()) {
- FilePath::StringType path = FilePath::FromWStringHack(cur_file).value();
+ FilePath cur_file;
+ while (!(cur_file = enumerator.Next()).value().empty()) {
+ FilePath::StringType path = cur_file.value();
// The file should not be returned twice.
EXPECT_TRUE(files_.end() == files_.find(path))
<< "Same file returned twice";
@@ -830,10 +830,10 @@ TEST_F(FileUtilTest, ReplaceExtensionTestWithPathSeparators) {
TEST_F(FileUtilTest, FileEnumeratorTest) {
// Test an empty directory.
- file_util::FileEnumerator f0(test_dir_.ToWStringHack(), true,
+ file_util::FileEnumerator f0(test_dir_, true,
file_util::FileEnumerator::FILES_AND_DIRECTORIES);
- EXPECT_EQ(f0.Next(), L"");
- EXPECT_EQ(f0.Next(), L"");
+ EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
+ EXPECT_EQ(f0.Next().value(), FILE_PATH_LITERAL(""));
// create the directories
FilePath dir1 = test_dir_.Append(FILE_PATH_LITERAL("dir1"));
@@ -857,7 +857,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
FilePath file2_abs = test_dir_.Append(FILE_PATH_LITERAL("file2.txt"));
// Only enumerate files.
- file_util::FileEnumerator f1(test_dir_.ToWStringHack(), true,
+ file_util::FileEnumerator f1(test_dir_, true,
file_util::FileEnumerator::FILES);
FindResultCollector c1(f1);
EXPECT_TRUE(c1.HasFile(file1));
@@ -867,7 +867,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c1.size(), 4);
// Only enumerate directories.
- file_util::FileEnumerator f2(test_dir_.ToWStringHack(), true,
+ file_util::FileEnumerator f2(test_dir_, true,
file_util::FileEnumerator::DIRECTORIES);
FindResultCollector c2(f2);
EXPECT_TRUE(c2.HasFile(dir1));
@@ -877,14 +877,14 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
// Only enumerate directories non-recursively.
file_util::FileEnumerator f2_non_recursive(
- test_dir_.ToWStringHack(), false, file_util::FileEnumerator::DIRECTORIES);
+ test_dir_, false, file_util::FileEnumerator::DIRECTORIES);
FindResultCollector c2_non_recursive(f2_non_recursive);
EXPECT_TRUE(c2_non_recursive.HasFile(dir1));
EXPECT_TRUE(c2_non_recursive.HasFile(dir2));
EXPECT_EQ(c2_non_recursive.size(), 2);
// Enumerate files and directories.
- file_util::FileEnumerator f3(test_dir_.ToWStringHack(), true,
+ file_util::FileEnumerator f3(test_dir_, true,
file_util::FileEnumerator::FILES_AND_DIRECTORIES);
FindResultCollector c3(f3);
EXPECT_TRUE(c3.HasFile(dir1));
@@ -897,7 +897,7 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c3.size(), 7);
// Non-recursive operation.
- file_util::FileEnumerator f4(test_dir_.ToWStringHack(), false,
+ file_util::FileEnumerator f4(test_dir_, false,
file_util::FileEnumerator::FILES_AND_DIRECTORIES);
FindResultCollector c4(f4);
EXPECT_TRUE(c4.HasFile(dir2));
@@ -907,8 +907,9 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_EQ(c4.size(), 4);
// Enumerate with a pattern.
- file_util::FileEnumerator f5(test_dir_.ToWStringHack(), true,
- file_util::FileEnumerator::FILES_AND_DIRECTORIES, L"dir*");
+ file_util::FileEnumerator f5(test_dir_, true,
+ file_util::FileEnumerator::FILES_AND_DIRECTORIES,
+ FILE_PATH_LITERAL("dir*"));
FindResultCollector c5(f5);
EXPECT_TRUE(c5.HasFile(dir1));
EXPECT_TRUE(c5.HasFile(dir2));
@@ -919,10 +920,10 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
// Make sure the destructor closes the find handle while in the middle of a
// query to allow TearDown to delete the directory.
- file_util::FileEnumerator f6(test_dir_.ToWStringHack(), true,
+ file_util::FileEnumerator f6(test_dir_, true,
file_util::FileEnumerator::FILES_AND_DIRECTORIES);
- EXPECT_FALSE(f6.Next().empty()); // Should have found something
- // (we don't care what).
+ EXPECT_FALSE(f6.Next().value().empty()); // Should have found something
+ // (we don't care what).
}
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index c32c87d..db22fa3 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -371,8 +371,9 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination,
}
bool IsDirectoryEmpty(const std::wstring& dir_path) {
- FileEnumerator files(dir_path, false, FileEnumerator::FILES_AND_DIRECTORIES);
- if (files.Next().empty())
+ FileEnumerator files(FilePath(dir_path),
+ false, FileEnumerator::FILES_AND_DIRECTORIES);
+ if (files.Next().value().empty())
return true;
return false;
}
@@ -596,7 +597,7 @@ bool SetCurrentDirectory(const FilePath& directory) {
///////////////////////////////////////////////
-FileEnumerator::FileEnumerator(const std::wstring& root_path,
+FileEnumerator::FileEnumerator(const FilePath& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type)
: recursive_(recursive),
@@ -606,10 +607,10 @@ FileEnumerator::FileEnumerator(const std::wstring& root_path,
pending_paths_.push(root_path);
}
-FileEnumerator::FileEnumerator(const std::wstring& root_path,
+FileEnumerator::FileEnumerator(const FilePath& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type,
- const std::wstring& pattern)
+ const FilePath::StringType& pattern)
: recursive_(recursive),
file_type_(file_type),
is_in_find_op_(false),
@@ -632,26 +633,24 @@ void FileEnumerator::GetFindInfo(FindInfo* info) {
memcpy(info, &find_data_, sizeof(*info));
}
-std::wstring FileEnumerator::Next() {
+FilePath FileEnumerator::Next() {
if (!is_in_find_op_) {
if (pending_paths_.empty())
- return std::wstring();
+ return FilePath();
// The last find FindFirstFile operation is done, prepare a new one.
- // root_path_ must have the trailing directory character.
root_path_ = pending_paths_.top();
- file_util::AppendToPath(&root_path_, std::wstring());
pending_paths_.pop();
// Start a new find operation.
- std::wstring src(root_path_);
+ FilePath src = root_path_;
- if (pattern_.empty())
- file_util::AppendToPath(&src, L"*"); // No pattern = match everything.
+ if (pattern_.value().empty())
+ src = src.Append(L"*"); // No pattern = match everything.
else
- file_util::AppendToPath(&src, pattern_);
+ src = src.Append(pattern_);
- find_handle_ = FindFirstFile(src.c_str(), &find_data_);
+ find_handle_ = FindFirstFile(src.value().c_str(), &find_data_);
is_in_find_op_ = true;
} else {
@@ -670,18 +669,18 @@ std::wstring FileEnumerator::Next() {
// in the root search directory, but for those directories which were
// matched, we want to enumerate all files inside them. This will happen
// when the handle is empty.
- pattern_.clear();
+ pattern_ = FilePath();
return Next();
}
- std::wstring cur_file(find_data_.cFileName);
+ FilePath cur_file(find_data_.cFileName);
// Skip over . and ..
- if (L"." == cur_file || L".." == cur_file)
+ if (L"." == cur_file.value() || L".." == cur_file.value())
return Next();
// Construct the absolute filename.
- cur_file.insert(0, root_path_);
+ cur_file = root_path_.Append(cur_file);
if (find_data_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (recursive_) {
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index a536591..0245ce6 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -71,15 +71,14 @@ bool ExtensionsServiceBackend::LoadExtensionsFromDirectory(
// Find all child directories in the install directory and load their
// manifests. Post errors and results to the frontend.
scoped_ptr<ExtensionList> extensions(new ExtensionList);
- file_util::FileEnumerator enumerator(path.ToWStringHack(),
+ file_util::FileEnumerator enumerator(path,
false, // not recursive
file_util::FileEnumerator::DIRECTORIES);
- for (std::wstring child_path = enumerator.Next(); !child_path.empty();
+ for (FilePath child_path = enumerator.Next(); !child_path.value().empty();
child_path = enumerator.Next()) {
- FilePath manifest_path = FilePath::FromWStringHack(child_path).Append(
- Extension::kManifestFilename);
+ FilePath manifest_path = child_path.Append(Extension::kManifestFilename);
if (!file_util::PathExists(manifest_path)) {
- ReportExtensionLoadError(frontend.get(), child_path,
+ ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
Extension::kInvalidManifestError);
continue;
}
@@ -88,13 +87,14 @@ bool ExtensionsServiceBackend::LoadExtensionsFromDirectory(
Value* root = NULL;
std::string error;
if (!serializer.Deserialize(&root, &error)) {
- ReportExtensionLoadError(frontend.get(), child_path, error);
+ ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
+ error);
continue;
}
scoped_ptr<Value> scoped_root(root);
if (!root->IsType(Value::TYPE_DICTIONARY)) {
- ReportExtensionLoadError(frontend.get(), child_path,
+ ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
Extension::kInvalidManifestError);
continue;
}
@@ -102,7 +102,8 @@ bool ExtensionsServiceBackend::LoadExtensionsFromDirectory(
scoped_ptr<Extension> extension(new Extension());
if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root),
&error)) {
- ReportExtensionLoadError(frontend.get(), child_path, error);
+ ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
+ error);
continue;
}
diff --git a/chrome/browser/greasemonkey_master.cc b/chrome/browser/greasemonkey_master.cc
index bb9e1a3..560f695 100644
--- a/chrome/browser/greasemonkey_master.cc
+++ b/chrome/browser/greasemonkey_master.cc
@@ -113,12 +113,12 @@ base::SharedMemory* GreasemonkeyMaster::ScriptReloader::GetNewScripts(
const FilePath& script_dir) {
std::vector<std::wstring> scripts;
- file_util::FileEnumerator enumerator(script_dir.value(), false,
+ file_util::FileEnumerator enumerator(script_dir, false,
file_util::FileEnumerator::FILES,
- L"*.user.js");
- for (std::wstring file = enumerator.Next(); !file.empty();
+ FILE_PATH_LITERAL("*.user.js"));
+ for (FilePath file = enumerator.Next(); !file.value().empty();
file = enumerator.Next()) {
- scripts.push_back(file);
+ scripts.push_back(file.ToWStringHack());
}
if (scripts.empty())
diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc
index ed280fe..12ba716 100644
--- a/chrome/browser/history/text_database_manager.cc
+++ b/chrome/browser/history/text_database_manager.cc
@@ -147,11 +147,12 @@ void TextDatabaseManager::InitDBList() {
present_databases_loaded_ = true;
// Find files on disk matching our pattern so we can quickly test for them.
- file_util::FileEnumerator enumerator(dir_, false,
+ file_util::FileEnumerator enumerator(FilePath::FromWStringHack(dir_), false,
file_util::FileEnumerator::FILES,
- std::wstring(TextDatabase::file_base()) + L"*");
+ FilePath::FromWStringHack(
+ std::wstring(TextDatabase::file_base()) + L"*").value());
std::wstring cur_file;
- while (!(cur_file = enumerator.Next()).empty()) {
+ while (!(cur_file = enumerator.Next().ToWStringHack()).empty()) {
// Convert to the number representing this file.
TextDatabase::DBIdent id = TextDatabase::FileNameToID(cur_file);
if (id) // Will be 0 on error.
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc
index aef2ba2..88da065 100644
--- a/chrome/browser/importer/firefox2_importer.cc
+++ b/chrome/browser/importer/firefox2_importer.cc
@@ -508,13 +508,13 @@ void Firefox2Importer::HTMLUnescape(std::wstring *text) {
void Firefox2Importer::FindXMLFilesInDir(
const std::wstring& dir,
std::vector<std::wstring>* xml_files) {
- file_util::FileEnumerator file_enum(dir, false,
+ file_util::FileEnumerator file_enum(FilePath::FromWStringHack(dir), false,
file_util::FileEnumerator::FILES,
- L"*.xml");
- std::wstring file(file_enum.Next());
+ FILE_PATH_LITERAL("*.xml"));
+ std::wstring file(file_enum.Next().ToWStringHack());
while (!file.empty()) {
xml_files->push_back(file);
- file = file_enum.Next();
+ file = file_enum.Next().ToWStringHack();
}
}
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc
index b171a9c..429b786 100644
--- a/chrome/browser/importer/ie_importer.cc
+++ b/chrome/browser/importer/ie_importer.cc
@@ -469,12 +469,13 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info,
BookmarkVector* bookmarks) {
std::wstring ie_folder = l10n_util::GetString(IDS_BOOKMARK_GROUP_FROM_IE);
BookmarkVector toolbar_bookmarks;
- std::wstring file;
+ FilePath file;
std::vector<std::wstring> file_list;
- file_util::FileEnumerator file_enumerator(info.path, true,
+ file_util::FileEnumerator file_enumerator(
+ FilePath::FromWStringHack(info.path), true,
file_util::FileEnumerator::FILES);
- while (!(file = file_enumerator.Next()).empty() && !cancelled())
- file_list.push_back(file);
+ while (!(file = file_enumerator.Next()).value().empty() && !cancelled())
+ file_list.push_back(file.ToWStringHack());
// Keep the bookmarks in alphabetical order.
std::sort(file_list.begin(), file_list.end());
diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc
index 213e199..8a15aa4 100644
--- a/chrome/browser/printing/printing_layout_uitest.cc
+++ b/chrome/browser/printing/printing_layout_uitest.cc
@@ -332,14 +332,15 @@ class PrintingLayoutTest : public PrintingTest<UITest> {
bool found_emf = false;
bool found_prn = false;
for (int i = 0; i < 100; ++i) {
- file_util::FileEnumerator enumerator(emf_path(), false,
- file_util::FileEnumerator::FILES);
+ file_util::FileEnumerator enumerator(
+ FilePath::FromWStringHack(emf_path()), false,
+ file_util::FileEnumerator::FILES);
emf_file.clear();
prn_file.clear();
found_emf = false;
found_prn = false;
std::wstring file;
- while (!(file = enumerator.Next()).empty()) {
+ while (!(file = enumerator.Next().ToWStringHack()).empty()) {
std::wstring ext = file_util::GetFileExtensionFromPath(file);
if (!_wcsicmp(ext.c_str(), L"emf")) {
EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" <<
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
index 4fa984d..7706a59 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
@@ -1114,9 +1114,10 @@ void UpdateDatabase(const std::wstring& initial_db,
if (!updates_path.empty()) {
std::wstring data_dir = GetFullSBDataPath(updates_path);
file_util::FileEnumerator file_enum(
- data_dir, false, file_util::FileEnumerator::FILES);
+ FilePath::FromWStringHack(data_dir), false,
+ file_util::FileEnumerator::FILES);
while (true) {
- std::wstring file = file_enum.Next();
+ std::wstring file = file_enum.Next().ToWStringHack();
if (file.empty())
break;
diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc
index 33bdf00..3353016 100644
--- a/chrome/browser/user_data_manager.cc
+++ b/chrome/browser/user_data_manager.cc
@@ -205,11 +205,11 @@ void UserDataManager::GetProfiles(std::vector<std::wstring>* profiles) const {
// This function should be called on the file thread.
DCHECK(MessageLoop::current() ==
ChromeThread::GetMessageLoop(ChromeThread::FILE));
- file_util::FileEnumerator file_enum(user_data_root_,
- false,
- file_util::FileEnumerator::DIRECTORIES);
+ file_util::FileEnumerator file_enum(
+ FilePath::FromWStringHack(user_data_root_),
+ false, file_util::FileEnumerator::DIRECTORIES);
std::wstring folder_name;
- while (!(folder_name = file_enum.Next()).empty()) {
+ while (!(folder_name = file_enum.Next().ToWStringHack()).empty()) {
folder_name = file_util::GetFilenameFromPath(folder_name);
std::wstring profile_name;
if (GetProfileNameFromFolderName(folder_name, &profile_name))
diff --git a/net/base/directory_lister.cc b/net/base/directory_lister.cc
index 00a67fab..a71c658 100644
--- a/net/base/directory_lister.cc
+++ b/net/base/directory_lister.cc
@@ -84,10 +84,10 @@ void DirectoryLister::ThreadMain() {
return;
}
- file_util::FileEnumerator file_enum(dir_.ToWStringHack(), false,
+ file_util::FileEnumerator file_enum(dir_, false,
file_util::FileEnumerator::FILES_AND_DIRECTORIES);
- while (!canceled_ && !(file_enum.Next().empty())) {
+ while (!canceled_ && !(file_enum.Next().value().empty())) {
file_enum.GetFindInfo(&e->data[e->count]);
if (++e->count == kFilesPerEvent) {
diff --git a/net/disk_cache/cache_util_posix.cc b/net/disk_cache/cache_util_posix.cc
index ca99cec..24ef4d5 100644
--- a/net/disk_cache/cache_util_posix.cc
+++ b/net/disk_cache/cache_util_posix.cc
@@ -16,9 +16,10 @@ bool MoveCache(const std::wstring& from_path, const std::wstring& to_path) {
}
void DeleteCache(const std::wstring& path, bool remove_folder) {
- file_util::FileEnumerator iter(path, /* recursive */ false,
+ file_util::FileEnumerator iter(FilePath::FromWStringHack(path),
+ /* recursive */ false,
file_util::FileEnumerator::FILES);
- for (std::wstring file = iter.Next(); !file.empty(); file = iter.Next()) {
+ for (FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) {
if (!file_util::Delete(file, /* recursive */ false))
NOTREACHED();
}
diff --git a/net/tools/dump_cache/dump_files.cc b/net/tools/dump_cache/dump_files.cc
index 1275254..4425d61 100644
--- a/net/tools/dump_cache/dump_files.cc
+++ b/net/tools/dump_cache/dump_files.cc
@@ -277,9 +277,10 @@ int DumpHeaders(const std::wstring input_path) {
std::wstring pattern(kDataPrefix);
pattern.append(L"*");
- file_util::FileEnumerator iter(input_path, false,
+ file_util::FileEnumerator iter(FilePath::FromWStringHack(input_path), false,
file_util::FileEnumerator::FILES, pattern);
- for (std::wstring file = iter.Next(); !file.empty(); file = iter.Next()) {
+ for (std::wstring file = iter.Next().ToWStringHack(); !file.empty();
+ file = iter.Next()) {
DumpBlockHeader(file);
}
diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc
index 4028d56..b3745fa 100644
--- a/webkit/tools/test_shell/image_decoder_unittest.cc
+++ b/webkit/tools/test_shell/image_decoder_unittest.cc
@@ -88,12 +88,13 @@ void ImageDecoderTest::SetUp() {
std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const {
std::wstring pattern = L"*." + format_;
- file_util::FileEnumerator enumerator(data_dir_, false,
+ file_util::FileEnumerator enumerator(FilePath::FromWStringHack(data_dir_),
+ false,
file_util::FileEnumerator::FILES);
std::vector<std::wstring> image_files;
std::wstring next_file_name;
- while ((next_file_name = enumerator.Next()) != L"") {
+ while ((next_file_name = enumerator.Next().ToWStringHack()) != L"") {
if (!MatchPattern(next_file_name, pattern)) {
continue;
}