summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 02:42:45 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 02:42:45 +0000
commit3bc9ffaf7c2a6ece95287c9a0ca0b895438a2444 (patch)
treef8314dfd653095024bf421de6eb5ae85fb10f24b /base
parent6e6fd1f47325dc85d9ae65cdbd9194d3e23bf9f4 (diff)
downloadchromium_src-3bc9ffaf7c2a6ece95287c9a0ca0b895438a2444.zip
chromium_src-3bc9ffaf7c2a6ece95287c9a0ca0b895438a2444.tar.gz
chromium_src-3bc9ffaf7c2a6ece95287c9a0ca0b895438a2444.tar.bz2
Fix FileEnumerator (win) for non-recursive, directory-only enumerations.
It previously only actually returned directories for recursive traversals. Review URL: http://codereview.chromium.org/7157 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util_unittest.cc8
-rw-r--r--base/file_util_win.cc5
2 files changed, 9 insertions, 4 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index c56579a..d4ebac6 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -885,6 +885,14 @@ TEST_F(FileUtilTest, FileEnumeratorTest) {
EXPECT_TRUE(c2.HasFile(dir2inner));
EXPECT_EQ(c2.size(), 3);
+ // Only enumerate directories non-recursively.
+ file_util::FileEnumerator f2_non_recursive(
+ 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_, true,
file_util::FileEnumerator::FILES_AND_DIRECTORIES);
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 7be172f..9c34ab3 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -683,11 +683,8 @@ std::wstring FileEnumerator::Next() {
// it to pending_paths_ so we scan it after we finish scanning this
// directory.
pending_paths_.push(cur_file);
- return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next();
}
-
- if ((file_type_ & FileEnumerator::DIRECTORIES) == 0)
- return Next();
+ return (file_type_ & FileEnumerator::DIRECTORIES) ? cur_file : Next();
}
return (file_type_ & FileEnumerator::FILES) ? cur_file : Next();
}