ewmscp  ..
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
moveRequestProvider Class Reference

#include <moveRequestProvider.h>

Inheritance diagram for moveRequestProvider:
[legend]
Collaboration diagram for moveRequestProvider:
[legend]

Public Member Functions

 moveRequestProvider (decltype(requests) aRequests, decltype(delayedRequests) aDelayedRequests, decltype(parents) aParents, decltype(InputHandler) aInputHandler, decltype(OutputHandler) aOutputHandler)
 
 ~moveRequestProvider () override=default
 
void processSources (const std::vector< std::string > &sources) override
 
- Public Member Functions inherited from cmdLineRequestProvider
 cmdLineRequestProvider (decltype(requests) aRequests, decltype(delayedRequests) aDelayedRequests, decltype(parents) aParents, decltype(InputHandler) aInputHandler, decltype(OutputHandler) aOutputHandler)
 
 ~cmdLineRequestProvider () override=default
 
bool isFollowMode () const override
 
void prepareMappings (std::vector< std::string > &sources, std::string &destination) override
 
void printMappings (std::ostream &stream) override
 
- Public Member Functions inherited from noFollowRequestProvider
 noFollowRequestProvider (decltype(requests) aRequests, decltype(delayedRequests) aDelayedRequests, decltype(parents) aParents, decltype(InputHandler) aInputHandler, decltype(OutputHandler) aOutputHandler)
 
 ~noFollowRequestProvider () override=default
 
bool isFollowMode () const override
 
void processSources (const std::vector< std::string > &sources) override
 
- Public Member Functions inherited from requestProvider
 requestProvider (decltype(requests) aRequests, decltype(delayedRequests) aDelayedRequests, decltype(parents) aParents, decltype(InputHandler) aInputHandler, decltype(OutputHandler) aOutputHandler)
 ! use only the file name part in the destination More...
 
virtual ~requestProvider ()=default
 

Private Member Functions

void processSource (const std::string &source) override
 
void addDirContent (const std::string &srcpath, const std::string &dstpath, const singleMap &mapEntry, const genericStat &dirStat) override
 

Private Attributes

std::list< copyRequest::base * > requestList
 

Static Private Attributes

static factoryTemplate< moveRequestProviderfactory
 

Additional Inherited Members

- Static Public Member Functions inherited from requestProvider
static requestProvidernewProvider (const std::string &choice, decltype(requests) aRequests, decltype(delayedRequests) aDelayedRequests, decltype(parents) aParents, decltype(InputHandler) aInputHandler, decltype(OutputHandler) aOutputHandler)
 
static void addAllowedNamesToOption (options::single< std::string > &option)
 
- Protected Member Functions inherited from cmdLineRequestProvider
const singleMapgetDstPath (const std::string &source, std::string &destination, bool baseNameOnly=false) override
 get detstination papth for a given source path More...
 
- Protected Member Functions inherited from noFollowRequestProvider
virtual copyRequest::basenewRequest (inputHandler::base *InputHandler, const std::string &aSource, const std::string &aDestination, std::unique_ptr< const genericStat > &aStat, const singleMap &aMapEntry, bool remove, copyRequest::clock_type::time_point timestamp)
 
- Static Protected Member Functions inherited from requestProvider
static std::map< std::string, factoryClass * > & getFactoryMap ()
 
- Protected Attributes inherited from cmdLineRequestProvider
bool processCmdLineDirs
 
- Protected Attributes inherited from requestProvider
copyRequest::simpleQueuerequests
 
copyRequest::timedQueuedelayedRequests
 
bool parents
 
inputHandler::baseInputHandler
 
outputHandler::baseOutputHandler
 
- Static Protected Attributes inherited from cmdLineRequestProvider
static options::single< bool > recursive
 
static options::single< bool > dereferenceCmdLine
 
static std::string singleDestination
 
- Static Protected Attributes inherited from noFollowRequestProvider
static options::single< std::string > & sourceDecodeMethod
 
static options::single< bool > ignoreMissing
 
static std::multiset< copyRequest::base *, copyRequest::base::pointerComparerequestSet
 
- Static Protected Attributes inherited from requestProvider
static options::map< std::string, pathMapTypepathMap
 
static singleMap badMapEntry
 

Detailed Description

Definition at line 5 of file moveRequestProvider.h.

Constructor & Destructor Documentation

◆ moveRequestProvider()

moveRequestProvider::moveRequestProvider ( decltype(requests aRequests,
decltype(delayedRequests aDelayedRequests,
decltype(parents aParents,
decltype(InputHandler aInputHandler,
decltype(OutputHandler aOutputHandler 
)
inline

Definition at line 17 of file moveRequestProvider.h.

21  :
22  cmdLineRequestProvider(aRequests, aDelayedRequests, aParents,
23  aInputHandler, aOutputHandler) {
24  };

◆ ~moveRequestProvider()

moveRequestProvider::~moveRequestProvider ( )
overridedefault

Member Function Documentation

◆ addDirContent()

void moveRequestProvider::addDirContent ( const std::string &  srcpath,
const std::string &  dstpath,
const singleMap mapEntry,
const genericStat dirStat 
)
overrideprivatevirtual

Reimplemented from cmdLineRequestProvider.

Definition at line 56 of file moveRequestProvider.cpp.

59  {
60  // with the subdir list we have only one open dir at a time
61  class subdirType {
62  public:
63  std::string srcPath;
64  std::string dstPath;
65  std::unique_ptr<const genericStat> dirStat;
66  subdirType(const std::string& aSrcPath,
67  const std::string& aDstPath,
68  std::unique_ptr<const genericStat>& aDirStat) :
69  srcPath(aSrcPath),
70  dstPath(aDstPath),
71  dirStat(std::move(aDirStat)) {};
72  };
73  std::list<subdirType> subdirs;
74  {
75  auto dir = InputHandler->getDirectory(srcpath);
76  while (auto entry = dir->getNextEntry(ignoreMissing)) {
77  std::string subpath(srcpath);
78  subpath += "/";
79  subpath += entry->getName();
80  std::string destpath(dstpath);
81  destpath += "/";
82  destpath += entry->getName();
83  auto entryStat = entry->getStat();
84 
85  if (entryStat->isDir() &&
86  entryStat->device == dirStat.device) {
87  subdirs.emplace_back(subpath, destpath, entryStat);
88  } else if (entryStat->isRegularFile() || entryStat->isLink()) {
89  requestList.push_front(new copyRequest::base(InputHandler, subpath, destpath,
90  subpath, subpath, mapEntry,
91  copyRequest::clock_type::now()));
92  }
93  }
94  }
95 
96  for (auto& subdir : subdirs) {
97  addDirContent(subdir.srcPath, subdir.dstPath, mapEntry, *(subdir.dirStat));
98  }
99 }

References genericStat::device, inputHandler::base::getDirectory(), noFollowRequestProvider::ignoreMissing, requestProvider::InputHandler, and requestList.

Referenced by processSource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processSource()

void moveRequestProvider::processSource ( const std::string &  source)
overrideprivatevirtual

Reimplemented from cmdLineRequestProvider.

Definition at line 8 of file moveRequestProvider.cpp.

8  {
9  auto sourceStat = InputHandler->getStat(source, dereferenceCmdLine);
10  if (!sourceStat) {
11  if (ignoreMissing) {
12  if (! quiet) {
14  source, "stat", "not found");
15  }
16  return;
17  }
18  throw std::runtime_error("can't stat " + source);
19  }
20  if (sourceStat->isDir()) {
21  if (recursive) {
22  std::string dstPath;
23  auto mapEntry = getDstPath(source, dstPath, true);
24  addDirContent(source, dstPath, mapEntry, *sourceStat);
25  } else {
26  throw std::runtime_error(source + " is a directory");
27  }
28  } else {
29  std::string dst;
30  auto mapEntry = getDstPath(source, dst, true);
31  requestList.push_front(new copyRequest::base(InputHandler, source, dst,
32  source, source, mapEntry,
33  copyRequest::clock_type::now()));
34  }
35 }

References addDirContent(), cmdLineRequestProvider::dereferenceCmdLine, errMsg::emit(), cmdLineRequestProvider::getDstPath(), pathHandler::getStat(), noFollowRequestProvider::ignoreMissing, requestProvider::InputHandler, quiet, cmdLineRequestProvider::recursive, requestList, and errMsg::warning.

Referenced by processSources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processSources()

void moveRequestProvider::processSources ( const std::vector< std::string > &  sources)
overridevirtual

Implements requestProvider.

Definition at line 37 of file moveRequestProvider.cpp.

37  {
38 
39  for (auto& source : sources) {
40  static auto escaper = escapism::newEscaper(sourceDecodeMethod);
41  if (escaper) {
42  std::string srcbuf;
43  escaper->deEscape(source, srcbuf);
44  processSource(srcbuf);
45  } else {
46  processSource(source);
47  }
48  }
49  for (auto request : requestList) {
50  std::unique_ptr<copyRequest::base> item(request);
51  requests.enqueue(item);
52  }
53  requestList.clear();
54 }

References waitQueues::simple< T >::enqueue(), escapism::newEscaper(), processSource(), requestList, requestProvider::requests, and noFollowRequestProvider::sourceDecodeMethod.

Here is the call graph for this function:

Member Data Documentation

◆ factory

factoryTemplate<moveRequestProvider> moveRequestProvider::factory
staticprivate

Definition at line 7 of file moveRequestProvider.h.

◆ requestList

std::list<copyRequest::base*> moveRequestProvider::requestList
private

Definition at line 9 of file moveRequestProvider.h.

Referenced by addDirContent(), processSource(), and processSources().


The documentation for this class was generated from the following files:
noFollowRequestProvider::ignoreMissing
static options::single< bool > ignoreMissing
Definition: noFollowRequestProvider.h:11
errMsg::level::warning
@ warning
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
inputHandler::base::getDirectory
virtual std::unique_ptr< Directory > getDirectory(const std::string &path)=0
noFollowRequestProvider::sourceDecodeMethod
static options::single< std::string > & sourceDecodeMethod
Definition: noFollowRequestProvider.h:10
cmdLineRequestProvider::getDstPath
const singleMap & getDstPath(const std::string &source, std::string &destination, bool baseNameOnly=false) override
get detstination papth for a given source path
Definition: cmdLineRequestProvider.cpp:18
cmdLineRequestProvider::recursive
static options::single< bool > recursive
Definition: cmdLineRequestProvider.h:13
copyRequest::base
class for copy requests.
Definition: copyRequest.h:99
moveRequestProvider::requestList
std::list< copyRequest::base * > requestList
Definition: moveRequestProvider.h:9
genericStat::device
dev_t device
Definition: genericStat.h:15
waitQueues::simple::enqueue
void enqueue(std::unique_ptr< T > &item)
Definition: waitQueues.h:37
requestProvider::requests
copyRequest::simpleQueue & requests
Definition: requestProvider.h:31
escapism::newEscaper
static const escapism * newEscaper(const std::string &name)
Definition: escapism.cpp:25
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
requestProvider::InputHandler
inputHandler::base * InputHandler
Definition: requestProvider.h:34
cmdLineRequestProvider::cmdLineRequestProvider
cmdLineRequestProvider(decltype(requests) aRequests, decltype(delayedRequests) aDelayedRequests, decltype(parents) aParents, decltype(InputHandler) aInputHandler, decltype(OutputHandler) aOutputHandler)
Definition: cmdLineRequestProvider.h:28
moveRequestProvider::addDirContent
void addDirContent(const std::string &srcpath, const std::string &dstpath, const singleMap &mapEntry, const genericStat &dirStat) override
Definition: moveRequestProvider.cpp:56
moveRequestProvider::processSource
void processSource(const std::string &source) override
Definition: moveRequestProvider.cpp:8
quiet
static options::single< bool > quiet('q', "quiet", "be quiet, no prefix to output lines")
cmdLineRequestProvider::dereferenceCmdLine
static options::single< bool > dereferenceCmdLine
Definition: cmdLineRequestProvider.h:14