 |
ewmscp
..
|
#include <outputHandlerLibssh.h>
|
| writerLibssh (const std::string &aPath, libsshCommon &aHandler, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData) |
|
| ~writerLibssh () noexcept(false) override |
|
void | closeAndRemoveBadCopy () override |
|
void | seek (size_t position) override |
|
size_t | getSize () const override |
|
void | writeBlock (const block &b) override |
|
void | doAttributePreservations (const genericStat &readInitialStat) override |
|
void | sync () override |
|
| libsshIoCommon (const std::string &aPath, libsshCommon &aHandler) |
|
std::unique_ptr< const genericStat > | getStat () override |
|
Public Member Functions inherited from ioHandle |
| ioHandle () |
|
virtual | ~ioHandle () noexcept(false) |
|
virtual bool | parallelizable () const |
| tell if this handler is capable of parallel IO. Unsually not the case More...
|
|
virtual void | setXattr (const std::string &, const std::string &) |
|
virtual std::string | getXattr (const std::string &) |
| get one extended attribute value More...
|
|
virtual void | removeXattr (const std::string &) |
|
virtual size_t | getBlockSize () const |
|
virtual void | setBlockSize (size_t newSize) |
|
virtual std::unique_ptr< attrDataType > | getAttrData (const outputHandler::base *) |
| get attributes in the optimal way for setting with aOutputHandler More...
|
|
virtual std::unique_ptr< acl::list > | getAclData () |
| get acls More...
|
|
Definition at line 13 of file outputHandlerLibssh.h.
◆ writerLibssh()
Definition at line 220 of file outputHandlerLibssh.cpp.
236 auto openMode = O_CREAT | O_TRUNC | O_WRONLY;
241 if (sftp_get_error(
handler.
sftp) != SSH_FX_NO_SUCH_FILE) {
246 sourceSize > readBlockSize) {
256 "can't open ",
path,
" for writing");
262 "can't stat destination file ",
path);
References copyRequest::append, throwcall::sftp::badval(), ioHandle::blockSize, enumAsBitmask< T >::clear(), libsshIoCommon::file, throwcall::sftp::good0(), libsshIoCommon::handler, libsshIoCommon::path, libsshCommon::sftp, timer::instanceUnscoped::stop(), timerInst, and writeInitialStat.
◆ ~writerLibssh()
outputHandler::libssh::writerLibssh::~writerLibssh |
( |
| ) |
|
|
overridenoexcept |
◆ closeAndRemoveBadCopy()
void outputHandler::libssh::writerLibssh::closeAndRemoveBadCopy |
( |
| ) |
|
|
override |
Definition at line 268 of file outputHandlerLibssh.cpp.
271 if (sftp_close(
file) == SSH_ERROR) {
273 path,
"close during unwind ",
279 path,
"unlink failed copy",
"due to exception");
282 if (retval && sftp_get_error(
handler.
sftp) != SSH_FX_NO_SUCH_FILE) {
284 path,
"can't remove bad copy ",
References errMsg::debug, errMsg::emit(), errMsg::err, timer::instanceUnscoped::stop(), and timerInst.
◆ doAttributePreservations()
void outputHandler::libssh::writerLibssh::doAttributePreservations |
( |
const genericStat & |
readInitialStat | ) |
|
|
override |
Definition at line 353 of file outputHandlerLibssh.cpp.
355 struct timeval times[2];
360 "can't set time stamp of ",
path);
366 "can't set mode of ",
path);
368 auto oldmask = umask(0);
371 "can't set mode of ",
path);
375 if (
gid != -1 ||
uid != -1) {
378 "can't set owner/group (",
uid,
",",
gid,
") of ",
path);
384 "can't set owner/group (", readInitialStat.
ownerUid,
",", readInitialStat.
ownerGid,
") of ",
References genericStat::getAtime(), genericStat::getMtime(), gid, throwcall::sftp::good0(), genericStat::mode, modeBits, genericStat::ownerGid, genericStat::ownerUid, preserve, timerInst, and uid.
◆ getSize()
size_t outputHandler::libssh::writerLibssh::getSize |
( |
| ) |
const |
|
override |
◆ seek()
void outputHandler::libssh::writerLibssh::seek |
( |
size_t |
position | ) |
|
|
override |
◆ sync()
void outputHandler::libssh::writerLibssh::sync |
( |
| ) |
|
|
override |
◆ writeBlock()
void outputHandler::libssh::writerLibssh::writeBlock |
( |
const block & |
b | ) |
|
|
override |
Definition at line 324 of file outputHandlerLibssh.cpp.
326 auto currentPosition = sftp_tell64(
file);
327 auto holeEnd = currentPosition + b.
size();
329 "can't seek to hole end (", holeEnd,
") in ",
path);
333 size_t bytes_writen_so_far = 0;
335 while (bytes_writen_so_far < b.
size()) {
336 auto count = b.
size() - bytes_writen_so_far;
343 auto bytes_writen = sftp_write(
file, b.
bufferAt(bytes_writen_so_far), count);
344 if (bytes_writen < 0) {
348 bytes_writen_so_far += bytes_writen;
References block::bufferAt(), throwcall::sftp::good0(), block::isHole(), block::size(), timerInst, throttle::watch::update(), throttle::watch::wait(), and writeRateLimit.
◆ attrData
◆ writeInitialStat
sftp_attributes outputHandler::libssh::writerLibssh::writeInitialStat |
|
protected |
The documentation for this class was generated from the following files:
class for defining the location of a error message in the source code.
void getAtime(struct timespec &spec) const
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
void closeAndRemoveBadCopy() override
void getMtime(struct timespec &spec) const
options::single< int > gid
size_t blockSize
in bytes, block size to be used when reading or writing
void * bufferAt(size_t offset)
only way to access the data in the block
libsshIoCommon(const std::string &aPath, libsshCommon &aHandler)
sftp_attributes writeInitialStat
decltype(preserve) preserve
set of properties to preserve in the copy
options::single< int > uid
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!
#define timerInst(subfunc)
throttle::watch writeRateLimit
void clear(const T aBits)
T badval(T call, t badvalue, libsshCommon &handler, const Args &... args)
void update(double units=1.0)
std::unique_ptr< ioHandle::attrDataType > attrData
options::single< modeBitType > modeBits
void good0(T call, libsshCommon &handler, const Args &... args)