From 577fc0845718ed8ad5bebf02a277c0579a817f77 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 17 May 2024 17:58:38 +0200 Subject: wanda: restructure source layout --- source/lib/include/wanda/system/filesystem.hpp | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 source/lib/include/wanda/system/filesystem.hpp (limited to 'source/lib/include/wanda/system/filesystem.hpp') diff --git a/source/lib/include/wanda/system/filesystem.hpp b/source/lib/include/wanda/system/filesystem.hpp new file mode 100644 index 0000000..971db90 --- /dev/null +++ b/source/lib/include/wanda/system/filesystem.hpp @@ -0,0 +1,39 @@ +/** + * @file filesystem.hpp + * @author Felix Morgner (felix.morgner@gmail.com) + * @since 1.0.0 + */ + +#ifndef WANDA_SYSTEM_FILESYSTEM_HPP +#define WANDA_SYSTEM_FILESYSTEM_HPP + +#include +#include +#include + +namespace wanda::system +{ + /** + * @brief Covenience alias for path lists + */ + using path_list = std::vector; + + /** + * @brief The default scan filter, allowing only regular files to pass + */ + constexpr inline auto default_filter = [](std::filesystem::path const & path) { + return is_regular_file(path); + }; + + /** + * @brief Scan the given folder for files + */ + std::optional scan(std::filesystem::path folder, bool(filter)(std::filesystem::path const &) = default_filter); + + /** + * @brief Pick a random path from the given list + */ + std::filesystem::path random_pick(path_list const & paths); +} // namespace wanda::system + +#endif \ No newline at end of file -- cgit v1.2.3