8 "map of source to destination directories");
12 static std::remove_reference<decltype(getFactoryMap())>::type map;
17 decltype(requests) aRequests,
18 decltype(delayedRequests) aDelayedRequests,
19 decltype(parents) aParents,
20 decltype(InputHandler) aInputHandler,
21 decltype(OutputHandler) aOutputHandler) {
22 return getFactoryMap()[choice]->create(aRequests, aDelayedRequests, aParents, aInputHandler, aOutputHandler);
31 std::string& destination,
33 for (
const auto& item :
pathMap) {
34 if (item.first.empty()
35 || source.find(item.first) == 0) {
36 destination = item.second;
37 if (destination.back() !=
'/') {
40 auto shortPath = source.substr(item.first.size());
41 while (!shortPath.empty() && shortPath.front() ==
'/') {
42 shortPath.erase(0, 1);
45 if (shortPath.find(
"./") == 0) {
46 destination += shortPath.substr(2);
48 destination += shortPath;
51 auto disposable_buffer = strdup(shortPath.c_str());
52 destination += basename(disposable_buffer);
53 free(disposable_buffer);
59 source,
"map paths",
"no dir mapping found");
60 for (
const auto& item :
pathMap) {
63 "candidate: ", item.first,
" -> ", item.second);
65 throw std::runtime_error(
"no dir mapping found for " + source);
71 std::string& destination) {
72 if (!destination.empty()) {
73 sources.push_back(destination);
77 throw std::runtime_error(
"no mapping given");
82 stream <<
"Path mapping:\n";
83 stream <<
"There are " <<
pathMap.size() <<
" directory mappings:\n";
84 for (
const auto& item :
pathMap) {
85 stream <<
"'" << item.first <<
"' -> '" << item.second <<
"'\n";