Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Directory Class Reference

#include <Directory.H>

Inheritance diagram for Directory:
Collaboration diagram for Directory:

Public Member Functions

 Directory (const std::string &s="")
 
 ~Directory ()
 
int open (const std::string &s="")
 
void close ()
 
 operator void * ()
 
bool operator! ()
 
 Directory (const std::string &s="")
 
 ~Directory ()
 
int open (const std::string &s="")
 
void close ()
 
 operator void * ()
 
bool operator! ()
 

Protected Attributes

std::string _path
 
bool _good
 
DIR * _dir
 

Additional Inherited Members

- Public Attributes inherited from vector< T >
elements
 STL member. More...
 

Detailed Description

Definition at line 26 of file Directory.H.

Constructor & Destructor Documentation

Directory ( const std::string &  s = "")

Definition at line 31 of file Directory.C.

References _dir, _good, _path, close(), and open().

32 {
33  _good = false;
34  _dir = NULL;
35  _path.assign(path);
36  if(open(path)){
37  std::cerr << "Directory::Error: Could not open " << path
38  << " as a directory." << std::endl;
39  _good = false;
40  }
41  else
42  close();
43 }
DIR * _dir
Definition: Directory.H:31
int open(const std::string &s="")
Definition: Directory.C:69
void close()
Definition: Directory.C:62
std::string _path
Definition: Directory.H:29
bool _good
Definition: Directory.H:30

Here is the call graph for this function:

~Directory ( )

Definition at line 45 of file Directory.C.

46 {
47  // Take the default
48 }
Directory ( const std::string &  s = "")
~Directory ( )

Member Function Documentation

void close ( )

Definition at line 62 of file Directory.C.

References _dir, and _good.

Referenced by Directory().

63 {
64  if(_good)
65  closedir(_dir);
66 }
DIR * _dir
Definition: Directory.H:31
bool _good
Definition: Directory.H:30

Here is the caller graph for this function:

void close ( )
int open ( const std::string &  s = "")

Definition at line 69 of file Directory.C.

References _dir, _good, and _path.

Referenced by Directory().

70 {
71  // if(_good){
72  // this->close();
73  _path = path;
74  // }
75  if(path.empty())
76  return(1);
77  if(!(_dir = opendir(path.c_str())))
78  return(1);
79  _path = path;
80  _good = true;
81  struct dirent *entry;
82  // Skip . and ..
83  entry = readdir(_dir);
84  entry = readdir(_dir);
85  while((entry = readdir(_dir)) != NULL)
86  this->push_back(entry->d_name);
87  return(0);
88 }
DIR * _dir
Definition: Directory.H:31
std::string _path
Definition: Directory.H:29
bool _good
Definition: Directory.H:30

Here is the caller graph for this function:

int open ( const std::string &  s = "")
operator void * ( )

Definition at line 50 of file Directory.C.

51 {
52  return(_good ? this : NULL);
53 }
bool _good
Definition: Directory.H:30
operator void * ( )
bool operator! ( )

Definition at line 56 of file Directory.C.

References _good.

57 {
58  return(!_good);
59 }
bool _good
Definition: Directory.H:30
bool operator! ( )

Member Data Documentation

DIR * _dir
protected

Definition at line 31 of file Directory.H.

Referenced by close(), Directory(), and open().

bool _good
protected

Definition at line 30 of file Directory.H.

Referenced by close(), Directory(), open(), and operator!().

std::string _path
protected

Definition at line 29 of file Directory.H.

Referenced by Directory(), and open().


The documentation for this class was generated from the following files: