summaryrefslogtreecommitdiff
path: root/src/files_finder.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/files_finder.hh')
-rw-r--r--src/files_finder.hh51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/files_finder.hh b/src/files_finder.hh
new file mode 100644
index 0000000..2928efa
--- /dev/null
+++ b/src/files_finder.hh
@@ -0,0 +1,51 @@
+#ifndef FILES_FINDER_HH
+#define FILES_FINDER_HH
+
+#include <memory>
+#include <filesystem>
+
+class Logger;
+class TaskRunner;
+
+class FilesFinder {
+public:
+ class Delegate {
+ public:
+ virtual ~Delegate() = default;
+
+ // Called on any thread, default implementation
+ // returns true for files not hidden.
+ // Depth is counted from root, files in root have depth zero.
+ virtual bool include_file(std::string_view name, uint16_t depth) const;
+
+ // Called on any thread, default implementation
+ // returns true for dirs not hidden.
+ // Depth is counted from root, files in root have depth zero.
+ virtual bool include_dir(std::string_view name, uint16_t depth) const;
+
+ // Called for each file found. Called on runner.
+ virtual void file(std::filesystem::path path) = 0;
+
+ // Called after all files have been found. Called on runner.
+ // Default implementation does nothing.
+ virtual void done();
+
+ protected:
+ Delegate() = default;
+ };
+
+ virtual ~FilesFinder() = default;
+
+ static std::unique_ptr<FilesFinder> create(std::shared_ptr<Logger> logger,
+ std::shared_ptr<TaskRunner> runner,
+ std::filesystem::path root,
+ Delegate* delegate,
+ size_t threads = 1);
+
+protected:
+ FilesFinder() = default;
+ FilesFinder(FilesFinder const&) = delete;
+ FilesFinder& operator=(FilesFinder const&) = delete;
+};
+
+#endif // FILES_HH