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

#include <inputHandlerPosixFile.h>

Inheritance diagram for inputHandler::posixFile::PosixDirectory:
[legend]
Collaboration diagram for inputHandler::posixFile::PosixDirectory:
[legend]

Public Member Functions

 PosixDirectory (const std::string &path)
 
 ~PosixDirectory () noexcept(false) override
 
std::unique_ptr< Entry > getNextEntry (bool ignoreMissing) override
 

Private Attributes

DIR * dir
 

Detailed Description

Definition at line 69 of file inputHandlerPosixFile.h.

Constructor & Destructor Documentation

◆ PosixDirectory()

inputHandler::posixFile::PosixDirectory::PosixDirectory ( const std::string &  path)

Definition at line 273 of file inputHandlerPosixFile.cpp.

273  : Directory(aPath) {
274  timerInst(opendir);
275  dir = throwcall::badval(opendir(path.c_str()), nullptr, "can't open directory ", path);
276  }

References throwcall::badval(), dir, and timerInst.

Here is the call graph for this function:

◆ ~PosixDirectory()

inputHandler::posixFile::PosixDirectory::~PosixDirectory ( )
overridenoexcept

Definition at line 277 of file inputHandlerPosixFile.cpp.

277  {
278  if (isUnwinding()) {
279  if (closedir(dir) != 0) {
281  "", "close directory during unwind ",
282  std::system_category().default_error_condition(errno).message());
283  }
284  } else {
285  timerInst(closedir);
286  throwcall::good0(closedir(dir), "can't close directory ", path);
287  }
288  }

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

Here is the call graph for this function:

Member Function Documentation

◆ getNextEntry()

std::unique_ptr< base::Directory::Entry > inputHandler::posixFile::PosixDirectory::getNextEntry ( bool  ignoreMissing)
override

Definition at line 289 of file inputHandlerPosixFile.cpp.

289  {
290  static timer::anchor a("readdir");
292  while (auto entry = readdir(dir)) {
293  i.stop();
294  if (entry->d_name[entry->d_name[0] != '.' ? 0 : entry->d_name[1] != '.' ? 1 : 2] == '\0') {
295  continue; // skip . .. and empty strings
296  i.restart();
297  }
298  struct stat statbuf;
299  {
300  timerInst(fstatat);
301  auto result = fstatat(dirfd(dir), entry->d_name, &statbuf, AT_SYMLINK_NOFOLLOW);
302  if (result != 0 && errno == ENOENT && ignoreMissing) {
303  continue;
304  }
305  throwcall::good0(result, "can't stat ", entry->d_name);
306  }
307  auto genStat = std::unique_ptr<const genericStat>(new genericStat(statbuf, std::chrono::nanoseconds(1)));
308  return std::unique_ptr<Entry>(new Entry(entry->d_name, genStat));
309  }
310  return nullptr;
311  }

References throwcall::good0(), timer::instanceUnscoped::restart(), timer::instanceUnscoped::stop(), and timerInst.

Here is the call graph for this function:

Member Data Documentation

◆ dir

DIR* inputHandler::posixFile::PosixDirectory::dir
private

Definition at line 70 of file inputHandlerPosixFile.h.

Referenced by PosixDirectory().


The documentation for this class was generated from the following files:
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
throwcall::badval
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
Definition: throwcall.h:54
genericStat
generic stat abstraction class Used to abstract the variants of the stat structure.
Definition: genericStat.h:12
errMsg::level::debug
@ debug
inputHandler::posixFile::PosixDirectory::dir
DIR * dir
Definition: inputHandlerPosixFile.h:70
timer::instanceUnscoped
Definition: timer.h:95
timer::anchor
Definition: timer.h:22
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
timerInst
#define timerInst(subfunc)
Definition: timer.h:157
throwcall::good0
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
Definition: throwcall.h:40