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

Function path_cat

example/http/server/sync/http_server_sync.cpp:72–95  ·  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

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

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected