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)

virtual ~ACE_Dirent_Selector (void)

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, int(*selector)(const ACE_DIRENT *d)=0, int(*comparator)(const ACE_DIRENT **d1, const ACE_DIRENT **d2)=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 35 of file Dirent_Selector.h.

Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Dirent_Selector::ACE_Dirent_Selector void   ) 


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]


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 43 of file Dirent_Selector.cpp.

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

Referenced by ~ACE_Dirent_Selector().

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

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,
int(*  selector)(const ACE_DIRENT *d) = 0,
int(*  comparator)(const ACE_DIRENT **d1, const ACE_DIRENT **d2) = 0

Open the directory dir and populate the array with directory entries that match the selector and comparator.

Definition at line 33 of file Dirent_Selector.cpp.

References ACE_TCHAR, n_, and ACE_OS::scandir().

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

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 64 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 61 of file Dirent_Selector.h.

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

The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:21:36 2006 for ACE by doxygen 1.3.6