diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2018-11-26 23:19:40 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2018-11-26 23:19:40 +0100 |
| commit | 97390d565eca8004edb1d262c282aaf9e47c3b7b (patch) | |
| tree | 7590e094e17a9e8732fc48b76b8f38c4ba866e9b /src/filesystem.hpp | |
| parent | bae92cea3bcbacd7883499da61a0e54f13da6d23 (diff) | |
| download | wanda-97390d565eca8004edb1d262c282aaf9e47c3b7b.tar.xz wanda-97390d565eca8004edb1d262c282aaf9e47c3b7b.zip | |
fs: implement filesystem access
Diffstat (limited to 'src/filesystem.hpp')
| -rw-r--r-- | src/filesystem.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/filesystem.hpp b/src/filesystem.hpp new file mode 100644 index 0000000..bcc9e5e --- /dev/null +++ b/src/filesystem.hpp @@ -0,0 +1,35 @@ +#ifndef WANDA_FILESYSTEM_HPP +#define WANDA_FILESYSTEM_HPP + +#include <filesystem> +#include <optional> +#include <vector> + +namespace wanda +{ + +/** + * @brief Covenience alias for path lists + */ +using path_list = std::vector<std::filesystem::path>; + +/** + * @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<path_list> 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 + +#endif
\ No newline at end of file |
