ewmscp  ..
Public Member Functions | Private Attributes | List of all members
inputHandler::libssh::SftpDirectory Class Reference

#include <inputHandlerLibssh.h>

Inheritance diagram for inputHandler::libssh::SftpDirectory:
[legend]
Collaboration diagram for inputHandler::libssh::SftpDirectory:
[legend]

Public Member Functions

 SftpDirectory (libsshCommon &aHandler, const std::string &aPath)
 
 ~SftpDirectory () noexcept(false) override
 
std::unique_ptr< Entry > getNextEntry (bool ignoreMissing) override
 

Private Attributes

libsshCommonhandler
 
sftp_dir dir
 

Detailed Description

Definition at line 40 of file inputHandlerLibssh.h.

Constructor & Destructor Documentation

◆ SftpDirectory()

inputHandler::libssh::SftpDirectory::SftpDirectory ( libsshCommon aHandler,
const std::string &  aPath 
)

Definition at line 159 of file inputHandlerLibssh.cpp.

160  :
161  Directory(aPath),
162  handler(aHandler) {
163  dir = throwcall::sftp::badval(sftp_opendir(handler.sftp, path.c_str()),
164  nullptr, handler,
165  "can't open directory ", path);
166  }

References throwcall::sftp::badval(), dir, handler, and libsshCommon::sftp.

Here is the call graph for this function:

◆ ~SftpDirectory()

inputHandler::libssh::SftpDirectory::~SftpDirectory ( )
overridenoexcept

Definition at line 167 of file inputHandlerLibssh.cpp.

167  {
168  if (isUnwinding()) {
169  if (sftp_closedir(dir) == SSH_ERROR) {
171  path, "close during unwind ",
172  "sftp error ", sftp_get_error(handler.sftp),
173  ", ssh error ", ssh_get_error(handler.session));
174  }
175  } else {
176  throwcall::sftp::badval(sftp_closedir(dir), SSH_ERROR, handler,
177  "can't close directory");
178  }
179  }

References throwcall::sftp::badval(), errMsg::debug, and errMsg::emit().

Here is the call graph for this function:

Member Function Documentation

◆ getNextEntry()

std::unique_ptr< base::Directory::Entry > inputHandler::libssh::SftpDirectory::getNextEntry ( bool  ignoreMissing)
override

Definition at line 180 of file inputHandlerLibssh.cpp.

180  {
181  while (auto entry = sftp_readdir(handler.sftp, dir)) {
182  if (entry->name[entry->name[0] != '.' ? 0 : entry->name[1] != '.' ? 1 : 2] == '\0') {
183  sftp_attributes_free(entry);
184  continue; // skip . .. and empty strings
185  }
186  auto genStat = std::unique_ptr<const genericStat>(new genericSftpStat(*entry,
187  handler.getVfsStat(path)));
188  auto retval = new Entry(entry->name, genStat);
189  sftp_attributes_free(entry);
190  return std::unique_ptr<Entry>(retval);
191  }
192  return nullptr;
193  }

Member Data Documentation

◆ dir

sftp_dir inputHandler::libssh::SftpDirectory::dir
private

Definition at line 42 of file inputHandlerLibssh.h.

Referenced by SftpDirectory().

◆ handler

libsshCommon& inputHandler::libssh::SftpDirectory::handler
private

Definition at line 41 of file inputHandlerLibssh.h.

Referenced by SftpDirectory().


The documentation for this class was generated from the following files:
libsshCommon::session
ssh_session session
Definition: libsshCommon.h:27
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
inputHandler::libssh::SftpDirectory::handler
libsshCommon & handler
Definition: inputHandlerLibssh.h:41
errMsg::level::debug
@ debug
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
inputHandler::libssh::SftpDirectory::dir
sftp_dir dir
Definition: inputHandlerLibssh.h:42
libsshCommon::sftp
sftp_session sftp
Definition: libsshCommon.h:28
genericSftpStat
Definition: libsshCommon.h:16
throwcall::sftp::badval
T badval(T call, t badvalue, libsshCommon &handler, const Args &... args)
Definition: libsshCommon.h:82
libsshCommon::getVfsStat
const sftp_statvfs_struct & getVfsStat(const std::string &path)
Definition: libsshCommon.cpp:152