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

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

Issue 2909943003: Removing useless Win7 checks + standardize its use (Closed)
Patch Set: Fix reversed conditionnal Created 3 years, 6 months 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
« no previous file with comments | « no previous file | base/path_service_unittest.cc » ('j') | base/win/shortcut.h » ('J')
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 <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "base/win/windows_version.h"
13 12
14 namespace base { 13 namespace base {
15 14
16 // FileEnumerator::FileInfo ---------------------------------------------------- 15 // FileEnumerator::FileInfo ----------------------------------------------------
17 16
18 FileEnumerator::FileInfo::FileInfo() { 17 FileEnumerator::FileInfo::FileInfo() {
19 memset(&find_data_, 0, sizeof(find_data_)); 18 memset(&find_data_, 0, sizeof(find_data_));
20 } 19 }
21 20
22 bool FileEnumerator::FileInfo::IsDirectory() const { 21 bool FileEnumerator::FileInfo::IsDirectory() const {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 pending_paths_.pop(); 94 pending_paths_.pop();
96 95
97 // Start a new find operation. 96 // Start a new find operation.
98 FilePath src = root_path_; 97 FilePath src = root_path_;
99 98
100 if (pattern_.empty()) 99 if (pattern_.empty())
101 src = src.Append(L"*"); // No pattern = match everything. 100 src = src.Append(L"*"); // No pattern = match everything.
102 else 101 else
103 src = src.Append(pattern_); 102 src = src.Append(pattern_);
104 103
105 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { 104 // Use a "large fetch" on newer Windows which should speed up large
Nico 2017/06/01 15:01:22 s/on newer Windows//
Patrick Monette 2017/06/02 00:34:04 Done.
106 // Use a "large fetch" on newer Windows which should speed up large 105 // enumerations (we seldom abort in the middle).
107 // enumerations (we seldom abort in the middle). 106 find_handle_ = FindFirstFileEx(src.value().c_str(),
108 find_handle_ = FindFirstFileEx(src.value().c_str(), 107 FindExInfoBasic, // Omit short name.
109 FindExInfoBasic, // Omit short name. 108 &find_data_,
110 &find_data_, 109 FindExSearchNameMatch,
111 FindExSearchNameMatch, 110 NULL,
112 NULL, 111 FIND_FIRST_EX_LARGE_FETCH);
113 FIND_FIRST_EX_LARGE_FETCH);
114 } else {
115 find_handle_ = FindFirstFile(src.value().c_str(), &find_data_);
116 }
117 has_find_data_ = true; 112 has_find_data_ = true;
118 } else { 113 } else {
119 // Search for the next file/directory. 114 // Search for the next file/directory.
120 if (!FindNextFile(find_handle_, &find_data_)) { 115 if (!FindNextFile(find_handle_, &find_data_)) {
121 FindClose(find_handle_); 116 FindClose(find_handle_);
122 find_handle_ = INVALID_HANDLE_VALUE; 117 find_handle_ = INVALID_HANDLE_VALUE;
123 } 118 }
124 } 119 }
125 120
126 if (INVALID_HANDLE_VALUE == find_handle_) { 121 if (INVALID_HANDLE_VALUE == find_handle_) {
(...skipping 30 matching lines...) Expand all
157 return cur_file; 152 return cur_file;
158 } else if (file_type_ & FileEnumerator::FILES) { 153 } else if (file_type_ & FileEnumerator::FILES) {
159 return cur_file; 154 return cur_file;
160 } 155 }
161 } 156 }
162 157
163 return FilePath(); 158 return FilePath();
164 } 159 }
165 160
166 } // namespace base 161 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/path_service_unittest.cc » ('j') | base/win/shortcut.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698