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

Function path_cat

example/http/server/flex/http_server_flex.cpp:76–99  ·  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

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

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected