ACE_Dirent_Selector Class Reference

Define a portable C++ directory-entry iterator based on the POSIX scandir API. More...

#include <Dirent_Selector.h>

List of all members.

Public Member Functions

 ACE_Dirent_Selector (void)
 Constructor.
virtual ~ACE_Dirent_Selector (void)
 Destructor.
int length (void) const
 Return the length of the list of matching directory entries.
ACE_DIRENT * operator[] (const int index) const
 Return the entry at index.
int close (void)
 Free up resources.
int open (const ACE_TCHAR *dir, ACE_SCANDIR_SELECTOR selector=0, ACE_SCANDIR_COMPARATOR comparator=0)

Protected Attributes

ACE_DIRENT ** namelist_
 Ptr to the namelist array.
int n_
 Number of entries in the array.


Detailed Description

Define a portable C++ directory-entry iterator based on the POSIX scandir API.

Definition at line 36 of file Dirent_Selector.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Dirent_Selector::ACE_Dirent_Selector ( void   ) 

Constructor.

Definition at line 20 of file Dirent_Selector.cpp.

00021   : namelist_ (0),
00022     n_ (0)
00023 {
00024 }

ACE_Dirent_Selector::~ACE_Dirent_Selector ( void   )  [virtual]

Destructor.

Definition at line 26 of file Dirent_Selector.cpp.

References close().

00027 {
00028   // Free up any allocated resources.
00029   this->close();
00030 }


Member Function Documentation

int ACE_Dirent_Selector::close ( void   ) 

Free up resources.

Definition at line 42 of file Dirent_Selector.cpp.

References ACE_OS::free(), n_, and namelist_.

Referenced by ~ACE_Dirent_Selector().

00043 {
00044   for (--n_; n_ >= 0; --n_)
00045     {
00046 #if defined (ACE_LACKS_STRUCT_DIR)
00047       // Only the lacking-struct-dir emulation allocates this. Native
00048       // scandir includes d_name in the dirent struct itself.
00049       ACE_OS::free (this->namelist_[n_]->d_name);
00050 #endif
00051       ACE_OS::free (this->namelist_[n_]);
00052     }
00053 
00054   ACE_OS::free (this->namelist_);
00055   this->namelist_ = 0;
00056   return 0;
00057 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Dirent_Selector::length ( void   )  const

Return the length of the list of matching directory entries.

Definition at line 8 of file Dirent_Selector.inl.

References n_.

00009 {
00010   return n_;
00011 }

int ACE_Dirent_Selector::open ( const ACE_TCHAR dir,
ACE_SCANDIR_SELECTOR  selector = 0,
ACE_SCANDIR_COMPARATOR  comparator = 0 
)

Open the directory dir and populate the current list of names with directory entries that match the selector and comparator.

Definition at line 33 of file Dirent_Selector.cpp.

References n_, and ACE_OS::scandir().

00036 {
00037   n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp);
00038   return n_;
00039 }

ACE_INLINE ACE_DIRENT * ACE_Dirent_Selector::operator[] ( const int  index  )  const

Return the entry at index.

Definition at line 14 of file Dirent_Selector.inl.

References namelist_.

00015 {
00016   return this->namelist_[n];
00017 }


Member Data Documentation

int ACE_Dirent_Selector::n_ [protected]

Number of entries in the array.

Definition at line 65 of file Dirent_Selector.h.

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

ACE_DIRENT** ACE_Dirent_Selector::namelist_ [protected]

Ptr to the namelist array.

Definition at line 62 of file Dirent_Selector.h.

Referenced by close(), and operator[]().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:03 2010 for ACE by  doxygen 1.4.7