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

Function path_cat

example/http/server/stackless/http_server_stackless.cpp:75–98  ·  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

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

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected