ewmscp  ..
Public Member Functions | Private Attributes | List of all members
scoped::Dir Class Reference

#include <scoped.h>

Collaboration diagram for scoped::Dir:
[legend]

Public Member Functions

 Dir (const std::string &Name, DIR *_Dir)
 
 Dir (const std::string &Name)
 
 ~Dir ()
 
DIR * operator() ()
 
 operator DIR * ()
 

Private Attributes

DIR * dir
 
const std::string & name
 

Detailed Description

Definition at line 71 of file scoped.h.

Constructor & Destructor Documentation

◆ Dir() [1/2]

scoped::Dir::Dir ( const std::string &  Name,
DIR *  _Dir 
)
inline

Definition at line 75 of file scoped.h.

75  :
76  dir(_Dir),
77  name(Name) {
78  }

◆ Dir() [2/2]

scoped::Dir::Dir ( const std::string &  Name)
inline

Definition at line 79 of file scoped.h.

79  :
80  name(Name) {
81  dir = throwcall::badval(opendir(name.c_str()),
82  nullptr, "can't open directory", name);
83  }

References throwcall::badval().

Here is the call graph for this function:

◆ ~Dir()

scoped::Dir::~Dir ( )
inline

Definition at line 84 of file scoped.h.

84  {
85  if (dir != nullptr) { // don't choke on non-open files...
86  throwcall::good0(closedir(dir), "can't close ", name);
87  }
88  }

References throwcall::good0().

Here is the call graph for this function:

Member Function Documentation

◆ operator DIR *()

scoped::Dir::operator DIR * ( )
inline

Definition at line 92 of file scoped.h.

92  {
93  return dir;
94  }

◆ operator()()

DIR* scoped::Dir::operator() ( )
inline

Definition at line 89 of file scoped.h.

89  {
90  return dir;
91  }

Member Data Documentation

◆ dir

DIR* scoped::Dir::dir
private

Definition at line 72 of file scoped.h.

◆ name

const std::string& scoped::Dir::name
private

Definition at line 73 of file scoped.h.


The documentation for this class was generated from the following file:
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
scoped::Dir::dir
DIR * dir
Definition: scoped.h:72
throwcall::good0
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
Definition: throwcall.h:40
scoped::Dir::name
const std::string & name
Definition: scoped.h:73