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

Function path_cat

example/advanced/server/advanced_server.cpp:80–103  ·  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

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

Callers 1

handle_requestFunction · 0.70

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected