diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
| commit | 6232d13f5321b87ddf12a1aa36b4545da45f173d (patch) | |
| tree | 23f3316470a14136debd9d02f9e920ca2b06f4cc /src/files_finder.hh | |
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in
memroy.
Diffstat (limited to 'src/files_finder.hh')
| -rw-r--r-- | src/files_finder.hh | 51 |
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 |
