// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_FILES_FILE_ENUMERATOR_H_ #define BASE_FILES_FILE_ENUMERATOR_H_ #include <stddef.h> #include <stdint.h> #include <vector> #include "base/base_export.h" #include "base/containers/stack.h" #include "base/files/file.h" #include "base/files/file_path.h" #include "base/functional/function_ref.h" #include "base/time/time.h" #include "build/build_config.h" #if BUILDFLAG(IS_WIN) #include "base/win/windows_types.h" #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) #include <sys/stat.h> #include <unistd.h> #include <unordered_map> #include <unordered_set> #endif namespace base { // A class for enumerating the files in a provided path. The order of the // results is not guaranteed. // // This is blocking. Do not use on critical threads. // // Example: // // base::FileEnumerator e(my_dir, false, base::FileEnumerator::FILES, // FILE_PATH_LITERAL("*.txt")); // Using `ForEach` with a lambda: // e.ForEach([](const base::FilePath& item) {...}); // Using a `for` loop: // for (base::FilePath name = e.Next(); !name.empty(); name = e.Next()) // ... class BASE_EXPORT FileEnumerator { … }; } // namespace base #endif // BASE_FILES_FILE_ENUMERATOR_H_