4#include <bnb/utils/defs.hpp>
11 namespace fs = std::filesystem;
12 using error_code = std::error_code;
13 using file_time_type = std::filesystem::file_time_type;
15 inline fs::path replace_extension(fs::path p,
const std::string& ext)
17 return p.replace_extension(std::string(
".") + ext);
20 std::string path_to_utf8(
const fs::path& p);
21 fs::path utf8_to_path(
const std::string& s);
23 inline std::string remove_trailing_separator(std::string strpath)
25 if (!strpath.empty() && (fs::path::preferred_separator == strpath[strpath.size() - 1])) {
26 strpath.erase(strpath.size() - 1);
31 template<
typename... T>
32 bool match_extesions(
const fs::path& path, T&&... extensions)
34 auto ext = bnb::path_to_utf8(path.extension());
35 std::transform(ext.begin(), ext.end(), ext.begin(), [](
unsigned char c) { return std::tolower(c); });
41 std::string ext_to_lower(extensions);
42 std::transform(ext_to_lower.begin(), ext_to_lower.end(), ext_to_lower.begin(), [](
unsigned char c) { return std::tolower(c); });
43 match = ext == ext_to_lower;