Chromium Code Reviews| Index: base/files/file_enumerator.h |
| diff --git a/base/files/file_enumerator.h b/base/files/file_enumerator.h |
| index 7cac8dd9d457f86366ea54adc1688d36f9121ed9..db59a5b12ec5388e3d96de4d6972bcda03758987 100644 |
| --- a/base/files/file_enumerator.h |
| +++ b/base/files/file_enumerator.h |
| @@ -84,6 +84,17 @@ class BASE_EXPORT FileEnumerator { |
| #endif |
| }; |
| + // Search policy for intermediate folders. |
| + enum class FolderSearchPolicy { |
| + // Recursive search will pass through folder which names matches pattern. |
|
Mark Mentovai
2017/05/19 17:16:11
folders whose names match the pattern
ivafanas
2017/05/22 04:42:28
Done.
|
| + // Inside each one, all files will be returned. Folders with names do not |
| + // matches pattern will be ignored within their interior. |
|
Mark Mentovai
2017/05/19 17:16:11
Folders with names that do not match the pattern
ivafanas
2017/05/22 04:42:28
Done.
|
| + MATCH_ONLY, |
| + // Recursive search will pass through any folder and perform pattern |
|
Mark Mentovai
2017/05/19 17:16:11
every folder
ivafanas
2017/05/22 04:42:28
Done.
|
| + // matching inside each one. |
| + ALL, |
| + }; |
| + |
| // |root_path| is the starting directory to search for. It may or may not end |
| // in a slash. |
| // |
| @@ -101,9 +112,6 @@ class BASE_EXPORT FileEnumerator { |
| // since the underlying code uses OS-specific matching routines. In general, |
| // Windows matching is less featureful than others, so test there first. |
| // If unspecified, this will match all files. |
| - // NOTE: the pattern only matches the contents of root_path, not files in |
| - // recursive subdirectories. |
| - // TODO(erikkay): Fix the pattern matching to work at all levels. |
| FileEnumerator(const FilePath& root_path, |
| bool recursive, |
| int file_type); |
| @@ -111,6 +119,11 @@ class BASE_EXPORT FileEnumerator { |
| bool recursive, |
| int file_type, |
| const FilePath::StringType& pattern); |
| + FileEnumerator(const FilePath& root_path, |
| + bool recursive, |
| + int file_type, |
| + const FilePath::StringType& pattern, |
| + FolderSearchPolicy folder_search_policy); |
|
Mark Mentovai
2017/05/19 17:16:11
I don’t see this being used anywhere yet, and ther
ivafanas
2017/05/22 04:42:28
It's a feature enhancement proposed in TODO messag
|
| ~FileEnumerator(); |
| // Returns the next file or an empty string if there are no more results. |
| @@ -126,29 +139,26 @@ class BASE_EXPORT FileEnumerator { |
| private: |
| // Returns true if the given path should be skipped in enumeration. |
| bool ShouldSkip(const FilePath& path); |
| + bool IsTypeMatched(bool is_dir); |
| + bool IsPatternMatched(const FilePath& src) const; |
| #if defined(OS_WIN) |
| // True when find_data_ is valid. |
| - bool has_find_data_; |
| + bool has_find_data_ = false; |
| WIN32_FIND_DATA find_data_; |
| - HANDLE find_handle_; |
| + HANDLE find_handle_ = INVALID_HANDLE_VALUE; |
| #elif defined(OS_POSIX) |
| - |
| - // Read the filenames in source into the vector of DirectoryEntryInfo's |
| - static bool ReadDirectory(std::vector<FileInfo>* entries, |
| - const FilePath& source, bool show_links); |
| - |
| // The files in the current directory |
| std::vector<FileInfo> directory_entries_; |
| // The next entry to use from the directory_entries_ vector |
| size_t current_directory_entry_; |
| #endif |
| - |
| FilePath root_path_; |
| bool recursive_; |
| int file_type_; |
| - FilePath::StringType pattern_; // Empty when we want to find everything. |
| + FilePath::StringType pattern_; |
| + FolderSearchPolicy folder_search_policy_; |
| // A stack that keeps track of which subdirectories we still need to |
| // enumerate in the breadth-first search. |