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

Side by Side Diff: base/files/file_enumerator_win.cc

Issue 48183005: Take advantage of some newer optimizations of FindFirstFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/files/file_enumerator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_enumerator.h" 5 #include "base/files/file_enumerator.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "base/win/windows_version.h"
11 12
12 namespace base { 13 namespace base {
13 14
14 // FileEnumerator::FileInfo ---------------------------------------------------- 15 // FileEnumerator::FileInfo ----------------------------------------------------
15 16
16 FileEnumerator::FileInfo::FileInfo() { 17 FileEnumerator::FileInfo::FileInfo() {
17 memset(&find_data_, 0, sizeof(find_data_)); 18 memset(&find_data_, 0, sizeof(find_data_));
18 } 19 }
19 20
20 bool FileEnumerator::FileInfo::IsDirectory() const { 21 bool FileEnumerator::FileInfo::IsDirectory() const {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 pending_paths_.pop(); 93 pending_paths_.pop();
93 94
94 // Start a new find operation. 95 // Start a new find operation.
95 FilePath src = root_path_; 96 FilePath src = root_path_;
96 97
97 if (pattern_.empty()) 98 if (pattern_.empty())
98 src = src.Append(L"*"); // No pattern = match everything. 99 src = src.Append(L"*"); // No pattern = match everything.
99 else 100 else
100 src = src.Append(pattern_); 101 src = src.Append(pattern_);
101 102
102 find_handle_ = FindFirstFile(src.value().c_str(), &find_data_); 103 if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
104 // Use a "large fetch" on newer Windows which should speed up large
105 // enumerations (we seldom abort in the middle).
106 find_handle_ = FindFirstFileEx(src.value().c_str(),
107 FindExInfoBasic, // Omit short name.
108 &find_data_,
109 FindExSearchNameMatch,
110 NULL,
111 FIND_FIRST_EX_LARGE_FETCH);
112 } else {
113 find_handle_ = FindFirstFile(src.value().c_str(), &find_data_);
114 }
103 has_find_data_ = true; 115 has_find_data_ = true;
104 } else { 116 } else {
105 // Search for the next file/directory. 117 // Search for the next file/directory.
106 if (!FindNextFile(find_handle_, &find_data_)) { 118 if (!FindNextFile(find_handle_, &find_data_)) {
107 FindClose(find_handle_); 119 FindClose(find_handle_);
108 find_handle_ = INVALID_HANDLE_VALUE; 120 find_handle_ = INVALID_HANDLE_VALUE;
109 } 121 }
110 } 122 }
111 123
112 if (INVALID_HANDLE_VALUE == find_handle_) { 124 if (INVALID_HANDLE_VALUE == find_handle_) {
(...skipping 29 matching lines...) Expand all
142 return cur_file; 154 return cur_file;
143 } else if (file_type_ & FileEnumerator::FILES) { 155 } else if (file_type_ & FileEnumerator::FILES) {
144 return cur_file; 156 return cur_file;
145 } 157 }
146 } 158 }
147 159
148 return FilePath(); 160 return FilePath();
149 } 161 }
150 162
151 } // namespace base 163 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_enumerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698