OSB_LIB::ScanDir Class Reference

Collaboration diagram for OSB_LIB::ScanDir:

Collaboration graph
[legend]
List of all members.

Detailed Description

Scan a directory.

Definition at line 110 of file osbfileutil.h.

Public Types

Public Member Functions

Public Attributes

Private Member Functions

Private Attributes

Classes


Member Typedef Documentation

typedef std::list<std::string> OSB_LIB::ScanDir::Result

Store the paths selected by Select::operator().

Definition at line 113 of file osbfileutil.h.


Constructor & Destructor Documentation

OSB_LIB::ScanDir::ScanDir ( const std::string &  dirPath  ) 

Constructor with directory to scan.

Parameters:
dirPath Path of directory to scan, see also setPath().

OSB_LIB::ScanDir::~ScanDir (  ) 

Destructor: deletes curEntry_.

OSB_LIB::ScanDir::ScanDir ( const ScanDir  )  [private]

Copy construction: not implemented.


Member Function Documentation

void OSB_LIB::ScanDir::delEntry ( dirent *&  entry  )  const [private]

Delete a dirent structure.

Parameters:
entry Pointer to dirent structure to delete.
It is set to 0 should have been allocated with mkEntry().

const std::string& OSB_LIB::ScanDir::dirPath (  )  const

Path of currently scanned directory.

void OSB_LIB::ScanDir::mkCurEntry (  )  [private]

Adjust the size of curEntry_.

dirent* OSB_LIB::ScanDir::mkEntry ( size_t  s  )  const [private]

Allocate memory for a dirent structure.

Parameters:
s Needed size, it should be pathconf(path, _PC_PATH_MAX)+1.
Returns:
A pointer to a dirent sturcture who's size is s.
Note:
Use delEntry() to delete the returned pointer.

The function signature deviates from the coding standard because struct dirent is of variable size and is allocated with new char[s]. Thus returning a std::auto_ptr would result in wrong deletion of the pointer.

ScanDir& OSB_LIB::ScanDir::operator= ( const ScanDir  )  [private]

Assignment operator: not implemented.

size_t OSB_LIB::ScanDir::scan ( Select select  ) 

Scan the directory.

Parameters:
select Function object that selects entries to include in result_.
Returns:
The number of entries in result_ or
-1 if opendir() on dirPath_ fails in which case errno contains the error (see man 3 opendir).
The function operator of Select is called for each directory entry in dirPath_, its return value defines the action:
-1: stop further scanning of dirPath_,
0: continue scanning,
else it it interpreted as bitmap. If it contains:
1: curEntry_ is added to result_.
2: the directory curEntry_ is processed recursivly.

In order to avoid infinite recursion a return value containing 2 is ignored if curEntry_ denotes the current directory (".") or its parent ("..").

Note:
If curEntry_ is not a directory and the return value contains 2, no error will result.

void OSB_LIB::ScanDir::setPath ( const std::string &  dirPath  ) 

Set the directory path.

Parameters:
dirPath New directory path to use. The current working directory ("./") is used if it is empty.
Calls mkCurEntry() to ensure the correct size of curEntry_.


Member Data Documentation

dirent* OSB_LIB::ScanDir::curEntry_ [private]

Buffer for readdir_r().

Note:
Use mkEntry() and delEntry() to allocate and delete it.

Definition at line 182 of file osbfileutil.h.

std::string OSB_LIB::ScanDir::dirPath_ [private]

Path of currently scanned directory.

Definition at line 175 of file osbfileutil.h.

size_t OSB_LIB::ScanDir::entrySize_ [private]

Size of curEntry_.

Definition at line 184 of file osbfileutil.h.

Result OSB_LIB::ScanDir::result_

Directory entries selected by Select::operator().

Definition at line 137 of file osbfileutil.h.


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:12:08 2006 for OSB Library by  doxygen 1.4.7