MCPcopy Create free account
hub / github.com/boostorg/beast / path_cat

Function path_cat

example/http/server/async-ssl/http_server_async_ssl.cpp:77–100  ·  view source on GitHub ↗

Append an HTTP rel-path to a local filesystem path. The returned path is normalized for the platform.

Source from the content-addressed store, hash-verified

75// Append an HTTP rel-path to a local filesystem path.
76// The returned path is normalized for the platform.
77std::string
78path_cat(
79 beast::string_view base,
80 beast::string_view path)
81{
82 if(base.empty())
83 return std::string(path);
84 std::string result(base);
85#ifdef BOOST_MSVC
86 char constexpr path_separator = '\\';
87 if(result.back() == path_separator)
88 result.resize(result.size() - 1);
89 result.append(path.data(), path.size());
90 for(auto& c : result)
91 if(c == '/')
92 c = path_separator;
93#else
94 char constexpr path_separator = '/';
95 if(result.back() == path_separator)
96 result.resize(result.size() - 1);
97 result.append(path.data(), path.size());
98#endif
99 return result;
100}
101
102// Return a response for the given request.
103//

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected