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

Function path_cat

example/advanced/server-flex/advanced_server_flex.cpp:84–107  ·  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

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

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected