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

Unified Diff: base/file_util_win.cc

Issue 13315: Move file enumeration to filepaths. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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_unittest.cc ('k') | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
===================================================================
--- base/file_util_win.cc (revision 6739)
+++ base/file_util_win.cc (working copy)
@@ -371,8 +371,9 @@
}
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 @@
///////////////////////////////////////////////
-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 @@
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 @@
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 @@
// 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_) {
« no previous file with comments | « base/file_util_unittest.cc ('k') | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698