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

Function path_cat

example/websocket/server/chat-multi/http_session.cpp:55–78  ·  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

53// Append an HTTP rel-path to a local filesystem path.
54// The returned path is normalized for the platform.
55std::string
56path_cat(
57 beast::string_view base,
58 beast::string_view path)
59{
60 if(base.empty())
61 return std::string(path);
62 std::string result(base);
63#ifdef BOOST_MSVC
64 char constexpr path_separator = '\\';
65 if(result.back() == path_separator)
66 result.resize(result.size() - 1);
67 result.append(path.data(), path.size());
68 for(auto& c : result)
69 if(c == '/')
70 c = path_separator;
71#else
72 char constexpr path_separator = '/';
73 if(result.back() == path_separator)
74 result.resize(result.size() - 1);
75 result.append(path.data(), path.size());
76#endif
77 return result;
78}
79
80// Return a response for the given request.
81//

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected