Volume Cartographer 2.27.0
FileFilters.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <regex>
6#include <string>
7#include <vector>
8
10
11namespace volcart
12{
13namespace io
14{
16using ExtensionList = std::vector<std::string>;
17
23 const filesystem::path& path, const ExtensionList& exts) -> bool
24{
25 std::string regexExpression = ".*\\.(";
26 std::size_t count = 0;
27 for (const auto& e : exts) {
28 regexExpression.append(e);
29 if (++count < exts.size()) {
30 regexExpression.append("|");
31 }
32 }
33 regexExpression.append(")$");
34
35 const std::regex extensions{regexExpression, std::regex::icase};
36 return std::regex_match(path.extension().string(), extensions);
37}
38
43inline auto UnixHiddenFileFilter(const filesystem::path& path) -> bool
44{
45 return path.filename().string()[0] == '.';
46}
47
48} // namespace io
49
52
55} // namespace volcart
auto FileExtensionFilter(const filesystem::path &path, const ExtensionList &exts) -> bool
Definition: FileFilters.hpp:22
std::vector< std::string > ExtensionList
Definition: FileFilters.hpp:16
auto UnixHiddenFileFilter(const filesystem::path &path) -> bool
Definition: FileFilters.hpp:43
Volume Cartographer library
constexpr auto IsFileType
Definition: FileFilters.hpp:51
constexpr auto IsUnixHiddenFile
Definition: FileFilters.hpp:54