From 6232d13f5321b87ddf12a1aa36b4545da45f173d Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 17 Nov 2021 22:34:57 +0100 Subject: Travel3: Simple image and video display site Reads the images and videos from filesystem and builds a site in memroy. --- src/files_finder.hh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/files_finder.hh (limited to 'src/files_finder.hh') 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 +#include + +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 create(std::shared_ptr logger, + std::shared_ptr 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 -- cgit v1.2.3-70-g09d2