opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
filesystem_helpers.h
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <functional>
5#include <span>
6#include <string_view>
7#include <vector>
8
9namespace osc
10{
11 // calls `consumer` with each file recursively found in `root` that ends with
12 // any of the provided `extensions`
14 const std::filesystem::path& root,
15 const std::function<void(std::filesystem::path)>& consumer,
16 std::span<const std::string_view> extensions
17 );
18
19 // returns all files found recursively in `root` that end with any of the provided
20 // `extensions`
21 std::vector<std::filesystem::path> find_files_with_extensions_recursive(
22 const std::filesystem::path& root,
23 std::span<const std::string_view> extensions
24 );
25
26 // calls `consumer` with each file recursively found in `root`
28 const std::filesystem::path& root,
29 const std::function<void(std::filesystem::path)>& consumer
30 );
31
32 // returns all files found recursively in `root`
33 std::vector<std::filesystem::path> find_files_recursive(
34 const std::filesystem::path& root
35 );
36
37 // returns true if `p1` is lexicographically greater than `p2`, ignoring case
38 //
39 // e.g. "b" > "a", "B" > "a" (this isn't true if case-sensitive)
40 bool is_filename_lexicographically_greater_than(const std::filesystem::path& p1, const std::filesystem::path& p2);
41
42 // returns true if `path` is within `dir` (non-recursive)
43 bool is_subpath(const std::filesystem::path& dir, const std::filesystem::path& path);
44}
Definition custom_decoration_generator.h:5
std::vector< std::filesystem::path > find_files_with_extensions_recursive(const std::filesystem::path &root, std::span< const std::string_view > extensions)
bool is_subpath(const std::filesystem::path &dir, const std::filesystem::path &path)
void for_each_file_with_extensions_recursive(const std::filesystem::path &root, const std::function< void(std::filesystem::path)> &consumer, std::span< const std::string_view > extensions)
bool is_filename_lexicographically_greater_than(const std::filesystem::path &p1, const std::filesystem::path &p2)
std::vector< std::filesystem::path > find_files_recursive(const std::filesystem::path &root)
constexpr U to(T &&value)
Definition conversion.h:56
void for_each_file_recursive(const std::filesystem::path &root, const std::function< void(std::filesystem::path)> &consumer)