ewmscp  ..
Classes | Public Member Functions | Static Public Attributes | Static Private Attributes | List of all members
outputHandler::davix Class Reference

#include <outputHandlerDavix.h>

Inheritance diagram for outputHandler::davix:
[legend]
Collaboration diagram for outputHandler::davix:
[legend]

Classes

class  writerDavix
 

Public Member Functions

 davix ()
 
 ~davix () override=default
 
std::unique_ptr< writernewWriter (const std::string &path, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType > aAttrData, std::unique_ptr< acl::list > aAclData) override
 
void ensureParentDirs (const std::string &path, const std::string &srcPath, inputHandler::base *InputHandler) override
 
void remove (const std::string &path, copyRequest::stateType &state) override
 
bool renameSimple (const std::string &fromPath, const std::string &toPath) override
 
base::renameRetvalType rename (const std::string &fromPath, const std::unique_ptr< const genericStat > &readInitialStat, const std::string &toPath, copyRequest::stateType &state) override
 
- Public Member Functions inherited from outputHandler::base
 ~base () override=default
 
virtual std::unique_ptr< writernewTmpWriter (std::string &path, size_t sourceSize, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData)
 
virtual void createSymlink (const std::vector< char > &, const std::string &, uid_t, gid_t)
 
virtual void doAttributePreservations (const std::string &, const genericStat &)
 
virtual size_t getMaxNameLength (const std::string &dirPath)
 
template<class C >
void shortenNameToMax (const std::string &path, C &pathBuf, const std::string &suffix)
 
- Public Member Functions inherited from pathHandler
virtual ~pathHandler ()=default
 
virtual std::string getXattr (const std::string &, const std::string &)
 
- Public Member Functions inherited from davixCommon
 davixCommon (davixConfigObject &configObj)
 
bool pathExists (const std::string &path) override
 
std::unique_ptr< const genericStatgetStat (const std::string &path, bool followLink) override
 

Static Public Attributes

static const std::string parPrefix
 

Static Private Attributes

static factoryTemplate< davixfactory
 

Additional Inherited Members

- Public Types inherited from outputHandler::base
enum  renameRetvalType { renameRetvalType::ok, renameRetvalType::fileChanged, renameRetvalType::fileVanished, renameRetvalType::cantHappen }
 
- Static Public Member Functions inherited from outputHandler::base
static basenewHandler (const std::string &name)
 
template<class T >
static void addAllowedNamesToOption (T &option)
 
- Static Public Member Functions inherited from davixCommon
static void getPassword (const std::string &prompt, std::string &password)
 
- Public Attributes inherited from davixCommon
Davix::RequestParams params
 
Davix::DavPosix posix
 
- Protected Member Functions inherited from outputHandler::base
 base ()=default
 
- Protected Member Functions inherited from davixCommon
int loginCallbackInner (std::string &login, std::string &password, int count)
 
- Static Protected Member Functions inherited from outputHandler::base
static std::map< std::string, factoryClass * > & getFactoryMap ()
 
- Static Protected Member Functions inherited from davixCommon
static int loginCallback (void *userdata, const Davix::SessionInfo &info, std::string &login, std::string &password, int count, Davix::DavixError **err)
 
- Protected Attributes inherited from davixCommon
Davix::Context context
 
std::string loginName
 
std::string passWord
 

Detailed Description

Definition at line 8 of file outputHandlerDavix.h.

Constructor & Destructor Documentation

◆ davix()

outputHandler::davix::davix ( )

Definition at line 29 of file outputHandlerDavix.cpp.

29  :
31  };

◆ ~davix()

outputHandler::davix::~davix ( )
overridedefault

Member Function Documentation

◆ ensureParentDirs()

void outputHandler::davix::ensureParentDirs ( const std::string &  path,
const std::string &  srcPath,
inputHandler::base InputHandler 
)
overridevirtual

Implements outputHandler::base.

Definition at line 35 of file outputHandlerDavix.cpp.

37  {
38  std::vector<std::remove_reference<decltype(path)>::type::value_type> disposable_buffer(path.c_str(), path.c_str() + path.size() + 1);
39  std::string dir(dirname(disposable_buffer.data()));
40  struct stat statbuf;
41  errorReport report(__func__, "stat", dir);
42  if (posix.stat(&params, dir, &statbuf, report) != 0) {
43  if (report->getStatus() == Davix::StatusCode::FileNotFound) {
44  ensureParentDirs(dir, srcPath, InputHandler);
45  errorReport report2(__func__, "mkdir", dir);
46  if (posix.mkdir(&params, dir, 0777u, report2) != 0) {
47  if (report2->getStatus() == Davix::StatusCode::FileExist) {
48  return; // we lost a race with another copy process...
49  }
50  report2.throwUp();
51  }
52  } else {
53  report.throwUp();
54  }
55  } else if (! S_ISDIR(statbuf.st_mode)) {
57  dir, "ensure parents",
58  "is not a directory (st_mode is ", statbuf.st_mode, ") but should be");
59  }
60  }

References errMsg::emit(), errMsg::info, davixCommon::params, davixCommon::posix, and errorReport::throwUp().

Here is the call graph for this function:

◆ newWriter()

std::unique_ptr< base::writer > outputHandler::davix::newWriter ( const std::string &  path,
bool  mightAppend,
size_t  sourceSize,
size_t  readBlockSize,
copyRequest::stateType state,
bool  noWrite,
std::unique_ptr< ioHandle::attrDataType aAttrData,
std::unique_ptr< acl::list aAclData 
)
overridevirtual

Implements outputHandler::base.

Definition at line 12 of file outputHandlerDavix.cpp.

19  {
20  return std::unique_ptr<base::writer>(new writerDavix(*this, path,
21  state, noWrite));
22  }

◆ remove()

void outputHandler::davix::remove ( const std::string &  path,
copyRequest::stateType state 
)
overridevirtual

Implements outputHandler::base.

Definition at line 63 of file outputHandlerDavix.cpp.

63  {
64  struct stat dsttat;
65  {
66  errorReport report(__func__, "stat", path);
67  if (posix.stat(&params, path, &dsttat, report) != 0) {
68  if (report->getStatus() == Davix::StatusCode::FileNotFound) {
70  return;
71  }
72  report.throwUp();
73  }
74  }
75  if (S_ISDIR(dsttat.st_mode)) {
76  errorReport report(__func__, "rmdir", path);
77  if (posix.rmdir(nullptr, path, report) != 0) {
78  if (report->getStatus() == Davix::StatusCode::FileNotFound) {
80  return;
81  } else if (report->getStatus() == Davix::StatusCode::FileExist) {
83  return;
84  } else {
85  report.throwUp();
86  }
87  } else {
89  return;
90  }
91  } else {
92  errorReport report(__func__, "unlink", path);
93  if (posix.unlink(&params, path, report) != 0) {
94  if (report->getStatus() == Davix::StatusCode::FileNotFound) {
96  return;
97  }
98  report.throwUp();
99  }
101  }
102  }

References copyRequest::done, copyRequest::failed, davixCommon::params, davixCommon::posix, errorReport::throwUp(), and copyRequest::vanished.

Here is the call graph for this function:

◆ rename()

base::renameRetvalType outputHandler::davix::rename ( const std::string &  fromPath,
const std::unique_ptr< const genericStat > &  readInitialStat,
const std::string &  toPath,
copyRequest::stateType state 
)
overridevirtual

Implements outputHandler::base.

Definition at line 128 of file outputHandlerDavix.cpp.

131  {
132  // we cannot be sure that the fromPath is up to date, always do a new copy
134  }

References outputHandler::base::fileChanged.

◆ renameSimple()

bool outputHandler::davix::renameSimple ( const std::string &  fromPath,
const std::string &  toPath 
)
overridevirtual

Implements outputHandler::base.

Definition at line 105 of file outputHandlerDavix.cpp.

106  {
107  {
108  // rename chokes when target already exists, so remove it beforehand
109  errorReport report(__func__, "unlink", toPath);
110  if (posix.unlink(&params, toPath, report) != 0) {
111  if (report->getStatus() != Davix::StatusCode::FileNotFound) {
112  report.throwUp();
113  }
114  }
115  }
116  {
117  errorReport report(__func__, "rename", fromPath);
118  if (posix.rename(&params, fromPath, toPath, report)) {
119  if (report->getStatus() == Davix::StatusCode::FileNotFound) {
120  return false;
121  }
122  report.throwUp();
123  }
124  }
125  return true;
126  }

References davixCommon::params, davixCommon::posix, and errorReport::throwUp().

Here is the call graph for this function:

Member Data Documentation

◆ factory

factoryTemplate<davix> outputHandler::davix::factory
staticprivate

Definition at line 9 of file outputHandlerDavix.h.

◆ parPrefix

const std::string outputHandler::davix::parPrefix
static

Definition at line 11 of file outputHandlerDavix.h.


The documentation for this class was generated from the following files:
outputHandler::outputConfig
static davixConfigObject outputConfig("davixOut")
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
errMsg::level::info
@ info
copyRequest::stateBitType::done
@ done
outputHandler::base::renameRetvalType::fileChanged
@ fileChanged
copyRequest::stateBitType::failed
@ failed
copyRequest::stateBitType::vanished
@ vanished
errorReport
class for easy error handling with davix ensures proper cleanup of the error report when going out of...
Definition: davixCommon.h:12
davixCommon::posix
Davix::DavPosix posix
Definition: davixCommon.h:198
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
davixCommon::davixCommon
davixCommon(davixConfigObject &configObj)
Definition: davixCommon.cpp:107
davixCommon::params
Davix::RequestParams params
Definition: davixCommon.h:197
outputHandler::davix::ensureParentDirs
void ensureParentDirs(const std::string &path, const std::string &srcPath, inputHandler::base *InputHandler) override
Definition: outputHandlerDavix.cpp:35