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

#include <inputHandlerDcap.h>

Inheritance diagram for inputHandler::dcap::dcapDirectory:
[legend]
Collaboration diagram for inputHandler::dcap::dcapDirectory:
[legend]

Public Member Functions

 dcapDirectory (const std::string &aPath)
 
 ~dcapDirectory () noexcept(false) override
 
std::unique_ptr< EntrygetNextEntry (bool ignoreMissing) override
 
- Public Member Functions inherited from inputHandler::base::Directory
 Directory (const std::string &aPath)
 
virtual ~Directory () noexcept(false)
 

Private Attributes

DIR * dir
 

Additional Inherited Members

- Protected Member Functions inherited from unwindCheck
 unwindCheck ()=default
 
 ~unwindCheck ()=default
 
bool isUnwinding () const
 
- Protected Attributes inherited from inputHandler::base::Directory
const std::string path
 

Detailed Description

Definition at line 32 of file inputHandlerDcap.h.

Constructor & Destructor Documentation

◆ dcapDirectory()

inputHandler::dcap::dcapDirectory::dcapDirectory ( const std::string &  aPath)

Definition at line 110 of file inputHandlerDcap.cpp.

110  :
112  dCapLock extraOptionLock;
113  dir = throwcall::dcap::badval(dc_opendir(path.c_str()), nullptr, "can't open directory ", path);
114  }

References throwcall::dcap::badval(), dir, and inputHandler::base::Directory::path.

Here is the call graph for this function:

◆ ~dcapDirectory()

inputHandler::dcap::dcapDirectory::~dcapDirectory ( )
overridenoexcept

Definition at line 115 of file inputHandlerDcap.cpp.

115  {
116  dCapLock extraOptionLock;
117  if (isUnwinding()) {
118  if (dc_closedir(dir) != 0) {
120  path, "close directory during unwind ",
121  dc_strerror(dc_errno));
122  }
123  } else {
124  throwcall::dcap::good0(dc_closedir(dir), "can't close directory ", path);
125  }
126  }

References errMsg::debug, errMsg::emit(), and throwcall::dcap::good0().

Here is the call graph for this function:

Member Function Documentation

◆ getNextEntry()

std::unique_ptr< base::Directory::Entry > inputHandler::dcap::dcapDirectory::getNextEntry ( bool  ignoreMissing)
overridevirtual

Implements inputHandler::base::Directory.

Definition at line 127 of file inputHandlerDcap.cpp.

127  {
128  dCapLock extraOptionLock;
129  while (auto entry = dc_readdir(dir)) {
130  if (entry->d_name[entry->d_name[0] != '.' ? 0 : entry->d_name[1] != '.' ? 1 : 2] == '\0') {
131  continue; // skip . .. and empty strings
132  }
133  struct dcapStat statbuf;
134  auto entrypath(dcapCommon::fixPathUrl(path + "/" + entry->d_name));
135  auto result = dc_stat(entrypath.c_str(), &statbuf);
136  if (result != 0 && errno == ENOENT && ignoreMissing) {
137  continue;
138  }
139  throwcall::dcap::good0(result, "can't stat ", entrypath);
140  auto genStat = std::unique_ptr<const genericStat>(new genericStat(statbuf, std::chrono::seconds(1)));
141  return std::unique_ptr<Entry>(new Entry(entry->d_name, genStat));
142  }
143  return nullptr;
144  }

References dcapStat, dcapCommon::fixPathUrl(), and throwcall::dcap::good0().

Here is the call graph for this function:

Member Data Documentation

◆ dir

DIR* inputHandler::dcap::dcapDirectory::dir
private

Definition at line 33 of file inputHandlerDcap.h.

Referenced by dcapDirectory().


The documentation for this class was generated from the following files:
throwcall::dcap::badval
T badval(T call, t badvalue, const Args &... args)
Definition: dcapCommon.h:28
inputHandler::dcap::dcapDirectory::dir
DIR * dir
Definition: inputHandlerDcap.h:33
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
unwindCheck::isUnwinding
bool isUnwinding() const
Definition: unwindCheck.h:19
dCapLock
Definition: dcapCommon.h:40
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
dcapStat
#define dcapStat
Definition: dcapCommon.h:7
errMsg::level::debug
@ debug
inputHandler::base::Directory::Directory
Directory(const std::string &aPath)
Definition: inputHandler.h:183
dcapCommon::fixPathUrl
static std::string fixPathUrl(const std::string &path)
Definition: dcapCommon.cpp:127
inputHandler::base::Directory::path
const std::string path
Definition: inputHandler.h:161
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
throwcall::dcap::good0
void good0(T call, const Args &... args)
Definition: dcapCommon.h:21