Вынесена функция 2

(cherry picked from commit e23977fdf0c870d677f37902b3ad0de23dc67e12)
This commit is contained in:
Антон
2025-04-18 17:36:48 +03:00
parent e6823ce506
commit b6c914f6f8
3 changed files with 29 additions and 36 deletions
+21
View File
@@ -53,4 +53,25 @@ boost::beast::string_view MimeType(boost::beast::string_view path) {
return "image/svg+xml";
return "application/text";
}
std::string PathCat(boost::beast::string_view base, boost::beast::string_view path){
if (base.empty())
return std::string(path);
std::string result(base);
#ifdef BOOST_MSVC
char constexpr path_separator = '\\';
if (result.back() == path_separator)
result.resize(result.size() - 1);
result.append(path.data(), path.size());
for (auto &c : result)
if (c == '/')
c = path_separator;
#else
char constexpr path_separator = '/';
if (result.back() == path_separator)
result.resize(result.size() - 1);
result.append(path.data(), path.size());
#endif
return result;
}
}