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

Function path_cat

example/http/server/async/http_server_async.cpp:74–97  ·  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

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

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected