OLD | NEW |
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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 base::Time FileEnumerator::FileInfo::GetLastModifiedTime() const { | 37 base::Time FileEnumerator::FileInfo::GetLastModifiedTime() const { |
38 return base::Time::FromFileTime(find_data_.ftLastWriteTime); | 38 return base::Time::FromFileTime(find_data_.ftLastWriteTime); |
39 } | 39 } |
40 | 40 |
41 // FileEnumerator -------------------------------------------------------------- | 41 // FileEnumerator -------------------------------------------------------------- |
42 | 42 |
43 FileEnumerator::FileEnumerator(const FilePath& root_path, | 43 FileEnumerator::FileEnumerator(const FilePath& root_path, |
44 bool recursive, | 44 bool recursive, |
45 int file_type) | 45 int file_type) |
46 : recursive_(recursive), | 46 : has_find_data_(false), |
47 file_type_(file_type), | 47 find_handle_(INVALID_HANDLE_VALUE), |
48 has_find_data_(false), | 48 recursive_(recursive), |
49 find_handle_(INVALID_HANDLE_VALUE) { | 49 file_type_(file_type) { |
50 // INCLUDE_DOT_DOT must not be specified if recursive. | 50 // INCLUDE_DOT_DOT must not be specified if recursive. |
51 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); | 51 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); |
52 memset(&find_data_, 0, sizeof(find_data_)); | 52 memset(&find_data_, 0, sizeof(find_data_)); |
53 pending_paths_.push(root_path); | 53 pending_paths_.push(root_path); |
54 } | 54 } |
55 | 55 |
56 FileEnumerator::FileEnumerator(const FilePath& root_path, | 56 FileEnumerator::FileEnumerator(const FilePath& root_path, |
57 bool recursive, | 57 bool recursive, |
58 int file_type, | 58 int file_type, |
59 const FilePath::StringType& pattern) | 59 const FilePath::StringType& pattern) |
60 : recursive_(recursive), | 60 : has_find_data_(false), |
| 61 find_handle_(INVALID_HANDLE_VALUE), |
| 62 recursive_(recursive), |
61 file_type_(file_type), | 63 file_type_(file_type), |
62 has_find_data_(false), | 64 pattern_(pattern) { |
63 pattern_(pattern), | |
64 find_handle_(INVALID_HANDLE_VALUE) { | |
65 // INCLUDE_DOT_DOT must not be specified if recursive. | 65 // INCLUDE_DOT_DOT must not be specified if recursive. |
66 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); | 66 DCHECK(!(recursive && (INCLUDE_DOT_DOT & file_type_))); |
67 memset(&find_data_, 0, sizeof(find_data_)); | 67 memset(&find_data_, 0, sizeof(find_data_)); |
68 pending_paths_.push(root_path); | 68 pending_paths_.push(root_path); |
69 } | 69 } |
70 | 70 |
71 FileEnumerator::~FileEnumerator() { | 71 FileEnumerator::~FileEnumerator() { |
72 if (find_handle_ != INVALID_HANDLE_VALUE) | 72 if (find_handle_ != INVALID_HANDLE_VALUE) |
73 FindClose(find_handle_); | 73 FindClose(find_handle_); |
74 } | 74 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return cur_file; | 155 return cur_file; |
156 } else if (file_type_ & FileEnumerator::FILES) { | 156 } else if (file_type_ & FileEnumerator::FILES) { |
157 return cur_file; | 157 return cur_file; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 return FilePath(); | 161 return FilePath(); |
162 } | 162 } |
163 | 163 |
164 } // namespace base | 164 } // namespace base |
OLD | NEW |