ewmscp  ..
policyRunRequestProvider.cpp
Go to the documentation of this file.
2 #include "throwcall.h"
3 #include "escapism.h"
4 #include "timer.h"
5 #include <errMsgQueue.h>
6 
9  "schema used for escaping file names in policy run file"));
10 
11 static void quietStatPrinter(std::ostream& aLogStream) {
12  if (printStatAnyway) {
14  }
15 }
16 void policyRunRequestProvider::processSource(const std::string& source) {
17  static auto escaper = escapism::newEscaper(escaperOption);
18  std::ifstream srcList(source);
19  std::string line;
20  while (std::getline(srcList, line)) {
21  auto separatorStart = line.find(" -- ");
22  if (separatorStart == std::string::npos) {
23  continue;
24  }
25  auto pathStart = separatorStart + 4; // length of " -- "
26  std::string src;
27  escaper->deEscape(line.substr(pathStart), src);
28  auto sourceStat = InputHandler->getStat(src, false); // never follow links
29  if (!sourceStat) {
30  if (ignoreMissing) {
31  if (! quiet) {
33  src, "stat", "not found");
34  }
35  continue;
36  }
37  throw std::runtime_error("can't stat " + src);
38  }
39  if (sourceStat->isDir()) { // directories are created on the fly, ignore here
40  continue;
41  }
42  std::string dst;
43  auto mapEntry = getDstPath(src, dst);
44  timerInst(emplace);
45  requestSet.emplace(new copyRequest::base(InputHandler, src, dst, sourceStat,
46  mapEntry,
47  false, copyRequest::clock_type::now()));
48  }
50 }
51 
noFollowRequestProvider::ignoreMissing
static options::single< bool > ignoreMissing
Definition: noFollowRequestProvider.h:11
errMsgQueue.h
errMsg::level::warning
@ warning
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
quietStatPrinter
static void quietStatPrinter(std::ostream &aLogStream)
Definition: policyRunRequestProvider.cpp:11
policyRunRequestProvider::processSource
void processSource(const std::string &source) override
Definition: policyRunRequestProvider.cpp:16
copyRequest::base
class for copy requests.
Definition: copyRequest.h:99
policyRunRequestProvider::factory
static factoryTemplate< policyRunRequestProvider > factory
Definition: policyRunRequestProvider.h:10
policyRunRequestProvider.h
copyRequest::base::setStatPrinter
static void setStatPrinter(void(*f)(std::ostream &))
Definition: copyRequest.cpp:1819
escapism.h
timer.h
throwcall.h
escapism::newEscaperOption
static options::single< std::string > * newEscaperOption(const std::string &name, const std::string &description, const std::string &defaultValue="Url")
Definition: escapism.cpp:36
copyRequest::base::printStats
static void printStats(std::ostream &stream)
Definition: copyRequest.cpp:1822
escapism::newEscaper
static const escapism * newEscaper(const std::string &name)
Definition: escapism.cpp:25
policyRunRequestProvider::escaperOption
static options::single< std::string > & escaperOption
Definition: policyRunRequestProvider.h:12
pathHandler::getStat
virtual std::unique_ptr< const genericStat > getStat(const std::string &path, bool followLink=true)=0
errMsg::emit
void emit(level aLogLevel, const location &loc, const std::string &aObject, const std::string &aAction, const Args &... args)
function to create and enqueue a message, this is the only way that messages should be created!
Definition: errMsgQueue.h:148
printStatAnyway
options::single< bool > printStatAnyway
timerInst
#define timerInst(subfunc)
Definition: timer.h:157
requestProvider::InputHandler
inputHandler::base * InputHandler
Definition: requestProvider.h:34
noFollowRequestProvider::requestSet
static std::multiset< copyRequest::base *, copyRequest::base::pointerCompare > requestSet
Definition: noFollowRequestProvider.h:13
requestProvider::getDstPath
virtual const singleMap & getDstPath(const std::string &source, std::string &destination, bool baseNameOnly=false)
get detstination papth for a given source path
Definition: requestProvider.cpp:30
quiet
static options::single< bool > quiet('q', "quiet", "be quiet, no prefix to output lines")
defineStatic
#define defineStatic(var,...)
defines a static variable and instatitates the constructor with the variable number of arguments.
Definition: ewmscp.h:42